Skip to content

Commit ce26c47

Browse files
committed
Modify utils.js and its test code
Signed-off-by: ambuj <[email protected]>
1 parent 17aff60 commit ce26c47

File tree

3 files changed

+99
-66
lines changed

3 files changed

+99
-66
lines changed

lib/helpers/utils.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4927,9 +4927,9 @@ export function parsePyProjectTomlFile(tomlFile) {
49274927
) {
49284928
poetryMode = true;
49294929
}
4930-
const requires = tomlData?.["build-system"]?.["requires"];
4931-
if (requires && Array.isArray(requires)) {
4932-
for (const req of requires) {
4930+
const buildRequires = tomlData?.["build-system"]?.["requires"];
4931+
if (buildRequires && Array.isArray(buildRequires)) {
4932+
for (const req of buildRequires) {
49334933
if (req.startsWith("poetry-core") && req.includes(">=2.0")) {
49344934
isPoetryV2 = true;
49354935
break;
@@ -13529,9 +13529,9 @@ export function getPipFrozenTree(
1352913529
});
1353013530
thoughtLog("Performing poetry install");
1353113531
let poetryInstallArgs = ["-m", "poetry", "install", "-n", "--no-root"];
13532-
const isPoetryV2 = parsePyProjectTomlFile(
13533-
join(basePath, "pyproject.toml"),
13534-
).isPoetryV2;
13532+
13533+
const pyprojectpath = safeExistsSync(join(basePath, "pyproject.toml"));
13534+
const isPoetryV2 = parsePyProjectTomlFile(pyprojectpath).isPoetryV2;
1353513535
// checking if poetryV2 is true or not
1353613536
if (isPoetryV2) {
1353713537
// Include all dependency groups and extras (Poetry v2+)

lib/helpers/utils.test.js

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4975,29 +4975,33 @@ test("parse pyproject.toml", () => {
49754975

49764976
test("parse pyproject.toml with poetryv2 requirement", () => {
49774977
const retMap = parsePyProjectTomlFile("./test/data/pyproject_poetryv2.toml");
4978-
// expect(retMap.parentComponent).toEqual({
4979-
// name: "cpggen",
4980-
// version: "1.9.0",
4981-
// description:
4982-
// "Generate CPG for multiple languages for code and threat analysis",
4983-
// license: "Apache-2.0",
4984-
// author: "Team AppThreat <[email protected]>",
4985-
// homepage: { url: "https://github.com/AppThreat/cpggen" },
4986-
// repository: { url: "https://github.com/AppThreat/cpggen" },
4987-
// tags: [
4988-
// "atom",
4989-
// "code analysis",
4990-
// "code property graph",
4991-
// "cpg",
4992-
// "joern",
4993-
// "static analysis",
4994-
// "threat analysis",
4995-
// ],
4996-
// type: "application",
4997-
// "bom-ref": "pkg:pypi/[email protected]",
4998-
// purl: "pkg:pypi/[email protected]",
4999-
// evidence: { identity: { field: "purl", confidence: 1, methods: [Array] } },
5000-
// });
4978+
expect(retMap.parentComponent).toEqual({
4979+
name: "blint",
4980+
version: "2.4.2",
4981+
description: "Linter and SBOM generator for binary files.",
4982+
license: "MIT",
4983+
authors: [{ name: "Team AppThreat", email: "[email protected]" }],
4984+
homepage: { url: "https://github.com/owasp-dep-scan/blint" },
4985+
repository: { url: "https://github.com/owasp-dep-scan/blint" },
4986+
tags: ["binary", "linter", "sast", "security"],
4987+
properties: [{ name: "cdx:pypi:requiresPython", value: ">=3.10,<3.14" }],
4988+
type: "application",
4989+
"bom-ref": "pkg:pypi/[email protected]",
4990+
purl: "pkg:pypi/[email protected]",
4991+
evidence: {
4992+
identity: {
4993+
field: "purl",
4994+
confidence: 1,
4995+
methods: [
4996+
{
4997+
technique: "manifest-analysis",
4998+
confidence: 1,
4999+
value: "./test/data/pyproject_poetryv2.toml",
5000+
},
5001+
],
5002+
},
5003+
},
5004+
});
50015005
expect(retMap.isPoetryV2).toBeTruthy();
50025006
});
50035007

test/data/pyproject_poetryv2.toml

Lines changed: 66 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,81 @@
1-
[tool.poetry]
2-
name = "cpggen"
3-
version = "1.9.0" # 1.9.0 is not version 2.0.0
4-
description = "Generate CPG for multiple languages for code and threat analysis"
5-
authors = ["Team AppThreat <[email protected]>"]
6-
license = "Apache-2.0"
1+
[project]
2+
name = "blint"
3+
version = "2.4.2"
4+
description = "Linter and SBOM generator for binary files."
5+
authors = [
6+
{name= "Team AppThreat", email = "[email protected]"},
7+
]
8+
dependencies = [
9+
"lief>=0.16.6",
10+
"rich>=14.0.0",
11+
"PyYAML>=6.0.2",
12+
"defusedxml>=0.7.1",
13+
"pydantic[email]>=2.11.3",
14+
"orjson>=3.10.16",
15+
"symbolic==10.2.1",
16+
"ar>=1.0.0",
17+
"custom-json-diff>=2.1.6",
18+
"appdirs>=1.4.4",
19+
"apsw>=3.49.1.0",
20+
"packageurl-python>=0.16.0",
21+
"oras>=0.2.28",
22+
]
23+
license = "MIT"
724
readme = "README.md"
8-
packages = [{include = "cpggen"}]
9-
homepage = "https://github.com/AppThreat/cpggen"
10-
repository = "https://github.com/AppThreat/cpggen"
11-
keywords = ["joern", "code analysis", "static analysis", "cpg", "code property graph", "atom", "threat analysis"]
25+
homepage = "https://github.com/owasp-dep-scan/blint"
26+
repository = "https://github.com/owasp-dep-scan/blint"
27+
keywords = ["linter", "binary", "security", "sast"]
1228
classifiers = [
1329
"Development Status :: 5 - Production/Stable",
1430
"Intended Audience :: Developers",
1531
"Intended Audience :: System Administrators",
1632
"Topic :: Utilities",
1733
"Topic :: Security",
18-
"Programming Language :: Python :: 3.8",
19-
"Programming Language :: Python :: 3.9",
2034
"Programming Language :: Python :: 3.10",
2135
"Programming Language :: Python :: 3.11",
36+
"Programming Language :: Python :: 3.12",
37+
"Programming Language :: Python :: 3.13",
2238
"Operating System :: OS Independent",
2339
]
24-
exclude = ["contrib", "tests"]
25-
include = ["cpggen/atom/*"]
26-
27-
[tool.poetry.scripts]
28-
atomgen = 'cpggen.cli:main'
29-
cpggen = 'cpggen.cli:main'
30-
cpg = 'cpggen.cli:main'
31-
32-
[tool.poetry.dependencies]
33-
python = ">=3.8.1,<3.12"
34-
rich = "^13.4.2"
35-
gitpython = "^3.1.31"
36-
quart = "^0.18.4"
37-
psutil = "^5.9.5"
38-
packageurl-python = "^0.11.1"
39-
httpx = "^0.24.1"
40-
41-
[tool.poetry.group.dev.dependencies]
42-
pytest = "^7.4.0"
43-
black = "^23.3.0"
44-
flake8 = "^6.0.0"
45-
pytest-cov = "^4.0.0"
46-
pyinstaller = "^5.12.0"
47-
bandit = "^1.7.5"
48-
pylint = "^2.17.4"
40+
requires-python = ">=3.10,<3.14"
41+
include = ["blint/data/*.yml"]
42+
43+
[project.urls]
44+
"CI" = "https://github.com/owasp-dep-scan/blint/actions"
45+
46+
[project.scripts]
47+
blint = 'blint.cli:main'
48+
49+
[project.optional-dependencies]
50+
dev = [
51+
"pytest>=8.3.5",
52+
"black>=25.1.0",
53+
"flake8>=7.2.0",
54+
"pylint>=3.3.6",
55+
"pytest-cov>=6.1.1",
56+
"pyinstaller>=6.12.0"
57+
]
58+
59+
[tool.black]
60+
line-length = 99
4961

5062
[build-system]
5163
requires = ["poetry-core>=2.0.0"]
5264
build-backend = "poetry.core.masonry.api"
65+
66+
[tool.pytest.ini_options]
67+
addopts = "--verbose --cov-append --cov-report term --cov blint"
68+
69+
[tool.pylint]
70+
generated-members = ["lief", "orjson"]
71+
ignore-paths = ["blint/cyclonedx/*", "tests/*"]
72+
# Let's not fuss about long strings
73+
ignore-long-lines = "[r|f]\""
74+
disable = ["missing-module-docstring", "logging-fstring-interpolation"]
75+
76+
[tool.pylint.format]
77+
max-line-length = 99
78+
79+
[tool.pylint.design]
80+
max-args = 6
81+
max-nested-blocks = 6

0 commit comments

Comments
 (0)