-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Moved initialization into a static from method - This separates how the object is created from what medium it can be created from - Changed get's to getOrDefaults - This allows nullpointers to be eaten and replaced with a default value - Removed affected and references - These are not used outside of parsing, so they should be removed - If they are needed in the future, we should parse them into proper objects, not the generic Object - Added tests to support the refactor
- Loading branch information
Showing
3 changed files
with
120 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
crawler/src/test/java/edu/rit/se/nvip/crawler/github/PyPaYamlFileTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package edu.rit.se.nvip.crawler.github; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.File; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
|
||
public class PyPaYamlFileTest { | ||
|
||
private final Path pypaResources = Paths.get("src", "test", "resources", "crawler", "github", "pypa"); | ||
|
||
@Test | ||
public void test_from_pysec_2023_173(){ | ||
PyPAYamlFile expected = new PyPAYamlFile( | ||
"PYSEC-2023-173", | ||
"Piccolo is an ORM and query builder which supports asyncio. In versions 0.120.0" + | ||
" and prior, the implementation of `BaseUser.login` leaks enough information to a" + | ||
" malicious user such that they would be able to successfully generate a list of valid" + | ||
" users on the platform. As Piccolo on its own does not also enforce strong passwords," + | ||
" these lists of valid accounts are likely to be used in a password spray attack with" + | ||
" the outcome being attempted takeover of user accounts on the platform. The impact" + | ||
" of this vulnerability is minor as it requires chaining with other attack vectors" + | ||
" in order to gain more then simply a list of valid users on the underlying platform." + | ||
" The likelihood of this vulnerability is possible as it requires minimal skills to" + | ||
" pull off, especially given the underlying login functionality for Piccolo based" + | ||
" sites is open source. This issue has been patched in version 0.121.0.", | ||
"Tue Sep 12 21:15:00 UTC 2023", | ||
"Tue Sep 19 05:26:00 UTC 2023", | ||
List.of("CVE-2023-41885", "GHSA-h7cm-mrvq-wcfr") | ||
); | ||
|
||
File pysec173Yaml = pypaResources.resolve(Paths.get("PYSEC-2023-173.yaml")).toFile(); | ||
PyPAYamlFile actual = PyPAYamlFile.from(pysec173Yaml); | ||
|
||
assertEquals(expected, actual); | ||
} | ||
|
||
@Test | ||
public void test_from_pysec_2023_174(){ | ||
PyPAYamlFile expected = new PyPAYamlFile( | ||
"PYSEC-2023-174", | ||
"imagecodecs versions before v2023.9.18 bundled libwebp binaries in wheels" + | ||
" that are vulnerable to CVE-2023-4863. imagecodecs v2023.9.18 upgrades the bundled" + | ||
" libwebp binary to v1.3.2.", | ||
"", | ||
"Wed Sep 20 05:12:42 UTC 2023", | ||
List.of() | ||
); | ||
|
||
File pysec174Yaml = pypaResources.resolve(Paths.get("PYSEC-2023-174.yaml")).toFile(); | ||
|
||
PyPAYamlFile actual = PyPAYamlFile.from(pysec174Yaml); | ||
|
||
assertEquals(expected, actual); | ||
} | ||
|
||
@Test | ||
public void test_get_cves_with_no_cves_returns_empty_list(){ | ||
List<String> expected = List.of(); | ||
|
||
PyPAYamlFile pyPaFile = new PyPAYamlFile( | ||
"", | ||
"", | ||
"", | ||
"", | ||
List.of() | ||
); | ||
|
||
assertEquals(expected, pyPaFile.getCves()); | ||
} | ||
|
||
@Test | ||
public void test_get_cves_returns_only_cves(){ | ||
List<String> expected = List.of("CVE-2023-41885"); | ||
|
||
PyPAYamlFile pyPaFile = new PyPAYamlFile( | ||
"", | ||
"", | ||
"", | ||
"", | ||
List.of("CVE-2023-41885", "GHSA-h7cm-mrvq-wcfr") | ||
); | ||
|
||
assertEquals(expected, pyPaFile.getCves()); | ||
} | ||
} |