Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions test/language_data_mini/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions test/language_data_mini/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
GIT
remote: https://github.com/matthewd/websocket-client-simple.git
revision: e161305f1a466b9398d86df3b1731b03362da91b
branch: close-race
specs:
websocket-client-simple (0.3.0)
event_emitter
websocket

GEM
remote: https://rubygems.org/
specs:
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
builder (3.2.4)
crack (0.4.5)
rexml
digest (3.1.0)
i18n (1.8.11)
concurrent-ruby (~> 1.0)
json (2.6.1)
jwt (2.3.0)
nokogiri (1.13.1-x86_64-linux)
racc (~> 1.4)
rack (2.2.3)
rake (13.0.6)

PLATFORMS
x86_64-linux

DEPENDENCIES
addressable
builder
crack
digest
i18n
json
jwt
nokogiri
rack
rake

BUNDLED WITH
2.3.3
39 changes: 39 additions & 0 deletions test/language_data_mini/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions test/language_data_mini/renv.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"R": {
"Version": "4.2.0",
"Repositories": [
{
"Name": "CRAN",
"URL": "https://cran.rstudio.com"
}
]
},
"Bioconductor": {
"Version": "3.15"
},
"Packages": {
"cli": {
"Package": "cli",
"Version": "3.2.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "e6c5f2e8b0c4e3c7e6f5e8e8e8e8e8e8",
"Requirements": []
},
"curl": {
"Package": "curl",
"Version": "4.3.2",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "e6c5f2e8b0c4e3c7e6f5e8e8e8e8e8e8",
"Requirements": []
},
"digest": {
"Package": "digest",
"Version": "0.6.29",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "e6c5f2e8b0c4e3c7e6f5e8e8e8e8e8e8",
"Requirements": []
},
"openssl": {
"Package": "openssl",
"Version": "1.4.6",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "e6c5f2e8b0c4e3c7e6f5e8e8e8e8e8e8",
"Requirements": []
},
"yaml": {
"Package": "yaml",
"Version": "2.3.5",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "e6c5f2e8b0c4e3c7e6f5e8e8e8e8e8e8",
"Requirements": []
},
"zip": {
"Package": "zip",
"Version": "2.2.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "e6c5f2e8b0c4e3c7e6f5e8e8e8e8e8e8",
"Requirements": []
}
}
}
95 changes: 62 additions & 33 deletions test/test_language_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,24 @@
from cve_bin_tool.log import LOGGER
from cve_bin_tool.version_scanner import VersionScanner

# Module-level paths for test fixtures
TEST_FILE_PATH = Path(__file__).parent.resolve() / "language_data"
TEST_FILE_PATH_MINI = Path(__file__).parent.resolve() / "language_data_mini"


def get_fixture_path(filename: str) -> Path:
"""Return mini fixture path for short tests, full path for long tests"""
if LONG_TESTS():
return TEST_FILE_PATH / filename
else:
return TEST_FILE_PATH_MINI / filename


class TestLanguageScanner:
"""Tests for various language scanners"""

TEST_FILE_PATH = Path(__file__).parent.resolve() / "language_data"
TEST_FILE_PATH = TEST_FILE_PATH
TEST_FILE_PATH_MINI = TEST_FILE_PATH_MINI

JAVASCRIPT_PRODUCTS = [
"cache",
Expand All @@ -27,6 +40,14 @@ class TestLanguageScanner:
"expect",
]

JAVASCRIPT_PRODUCTS_MINI = [
"cache",
"core",
"http-client",
"generator",
"expect",
]

RUST_PRODUCTS = [
"bumpalo",
"cranelift-codegen",
Expand Down Expand Up @@ -54,6 +75,17 @@ class TestLanguageScanner:
"yaml-rust",
]

RUST_PRODUCTS_MINI = [
"bumpalo",
"cranelift-codegen",
"crossbeam-channel",
"digest",
"generic-array",
"hex",
"libc",
"linked-hash-map",
]

RUBY_PRODUCTS = [
"addressable",
"backburner",
Expand Down Expand Up @@ -104,6 +136,18 @@ class TestLanguageScanner:
"websocket-extensions",
]

RUBY_PRODUCTS_MINI = [
"addressable",
"builder",
"crack",
"digest",
"i18n",
"json",
"jwt",
"rack",
"rake",
]

R_PRODUCTS = [
"cli",
"clipr",
Expand All @@ -124,6 +168,15 @@ class TestLanguageScanner:
"zip",
]

R_PRODUCTS_MINI = [
"cli",
"curl",
"digest",
"openssl",
"yaml",
"zip",
]

PYTHON_PRODUCTS = [
"plotly",
"zstandard",
Expand Down Expand Up @@ -239,40 +292,22 @@ def test_language_package_none_found(self, filename: str) -> None:
"filename,parser_class,products,namespace",
[
pytest.param(
str(TEST_FILE_PATH / "renv.lock"),
str(get_fixture_path("renv.lock")),
parsers.r.RParser,
R_PRODUCTS,
R_PRODUCTS if LONG_TESTS() else R_PRODUCTS_MINI,
"cran",
marks=[
pytest.mark.skipif(
not LONG_TESTS(),
reason="Test reduction in short tests",
)
],
),
pytest.param(
str(TEST_FILE_PATH / "Cargo.lock"),
str(get_fixture_path("Cargo.lock")),
parsers.rust.RustParser,
RUST_PRODUCTS,
RUST_PRODUCTS if LONG_TESTS() else RUST_PRODUCTS_MINI,
"cargo",
marks=[
pytest.mark.skipif(
not LONG_TESTS(),
reason="Test reduction in short tests",
)
],
),
pytest.param(
str(TEST_FILE_PATH / "Gemfile.lock"),
str(get_fixture_path("Gemfile.lock")),
parsers.ruby.RubyParser,
RUBY_PRODUCTS,
RUBY_PRODUCTS if LONG_TESTS() else RUBY_PRODUCTS_MINI,
"gem",
marks=[
pytest.mark.skipif(
not LONG_TESTS(),
reason="Test reduction in short tests",
)
],
),
pytest.param(
str(TEST_FILE_PATH / "requirements.txt"),
Expand All @@ -287,16 +322,10 @@ def test_language_package_none_found(self, filename: str) -> None:
],
),
pytest.param(
str(TEST_FILE_PATH / "package-lock.json"),
str(get_fixture_path("package-lock.json")),
parsers.javascript.JavascriptParser,
JAVASCRIPT_PRODUCTS,
JAVASCRIPT_PRODUCTS if LONG_TESTS() else JAVASCRIPT_PRODUCTS_MINI,
"npm",
marks=[
pytest.mark.skipif(
not LONG_TESTS(),
reason="Test reduction in short tests",
)
],
),
pytest.param(
str(TEST_FILE_PATH / "go.mod"),
Expand Down