Skip to content

Conversation

omriyoffe-panw
Copy link
Contributor

A suggested fix for
#1891

@omriyoffe-panw omriyoffe-panw requested a review from prabhu as a code owner July 6, 2025 11:21
@omriyoffe-panw omriyoffe-panw force-pushed the bugfix/requirements-txt-wrong-technique branch from a5571ed to 2e8c244 Compare July 6, 2025 11:24
@malice00
Copy link
Collaborator

malice00 commented Jul 7, 2025

Can you please run the linter (pnpm run lint) to fix the problem with biome?

@omriyoffe-panw
Copy link
Contributor Author

omriyoffe-panw commented Jul 8, 2025

Can you please run the linter (pnpm run lint) to fix the problem with biome?

@malice00
Done

lib/cli/index.js Outdated
const directDependencies = await parseReqFile(reqData, true);
if (directDependencies?.length) {
// Mark direct dependencies from requirements.txt as manifest-analysis
directDependencies.forEach((pkg) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add this evidence creation in the parseReqFile method instead? This way the index.js could remain a bit lightweight.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

lib/cli/index.js Outdated
// Also mark the evidence
if (!pkg.evidence) {
pkg.evidence = {
identity: { field: "purl", confidence: 1, methods: [] },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a lower confidence value such as 0.5 or even 0.3 when there are no version.s

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -3858,6 +3886,35 @@ export async function createPythonBom(path, options) {
parentComponent,
);
if (pkgMap.pkgList?.length) {
pkgMap.pkgList.forEach((pkg) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this logic overwrite and set a single manifest-analysis technique or add to the existing array?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the package has already been found, it will use it's technique. Otherwise it will set it as manifest-analysis

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can index.js know that those packages were found using manifest-analysis? Can we move this to utils.js as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the packageTechniqueMap. I can create a function for this in the utils.js if that is what you mean

pkg.evidence = {
identity: {
field: "purl",
confidence: pkg.version ? 1 : 0.3,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use 0.5 instead of 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}
pkg.evidence.identity.methods.push({
technique: "manifest-analysis",
confidence: 1,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same confidence logic as line 5792

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: Omri Yoffe <oyoffe@paloaltonetworks.com>
@omriyoffe-panw omriyoffe-panw force-pushed the bugfix/requirements-txt-wrong-technique branch from dbad80c to 93b314c Compare July 9, 2025 10:53
@prabhu
Copy link
Collaborator

prabhu commented Jul 9, 2025

Some test failures. Please take a look at your convenience.

Signed-off-by: Omri Yoffe <oyoffe@paloaltonetworks.com>
Signed-off-by: Omri Yoffe <oyoffe@paloaltonetworks.com>
Signed-off-by: Omri Yoffe <oyoffe@paloaltonetworks.com>
Signed-off-by: Omri Yoffe <oyoffe@paloaltonetworks.com>
@omriyoffe-panw omriyoffe-panw force-pushed the bugfix/requirements-txt-wrong-technique branch from 93b314c to eb581c9 Compare July 9, 2025 12:41
Signed-off-by: Omri Yoffe <oyoffe@paloaltonetworks.com>
@omriyoffe-panw
Copy link
Contributor Author

Some test failures. Please take a look at your convenience.

Fixed

@prabhu
Copy link
Collaborator

prabhu commented Jul 10, 2025

Thank you so much. Give us some time since we are running behind with testing, as everything is quite manual.

@omriyoffe-panw
Copy link
Contributor Author

@prabhu Thank you, do you have an estimate when will you be able to test this?

Copy link
Collaborator

@prabhu prabhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Will test it on master directly.

@prabhu prabhu merged commit c0b3a87 into CycloneDX:master Jul 16, 2025
78 checks passed
@@ -3847,6 +3848,10 @@ export async function createPythonBom(path, options) {
const basePath = dirname(f);
let reqData;
let frozen = false;

reqData = readFileSync(f, { encoding: "utf-8" });
await parseReqFile(reqData, true, packageTechniqueMap);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@omriyoffe-panw This line is dangling and isn't doing anything. What was the idea behind this?

pkg.evidence.identity.methods =
pkg.evidence.identity.methods.map((method) => ({
...method,
technique: "manifest-analysis",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is also not correct since it overwrites technique instead of adding to the array.

For example, in the below the technique is getting overwritten to manifest-analysis.

{
      "group": "",
      "name": "starlette",
      "version": "0.46.2",
      "purl": "pkg:pypi/starlette@0.46.2",
      "type": "library",
      "bom-ref": "pkg:pypi/starlette@0.46.2",
      "properties": [
        {
          "name": "SrcFile",
          "value": "requirements.txt"
        }
      ],
      "evidence": {
        "identity": [
          {
            "field": "purl",
            "confidence": 1,
            "methods": [
              {
                "technique": "manifest-analysis",
                "confidence": 1,
                "value": "/Users/prabhu/miniconda3/envs/2069"
              }
            ],
            "concludedValue": "/Users/prabhu/miniconda3/envs/2069"
          }
        ]
      }
    }

@prabhu
Copy link
Collaborator

prabhu commented Jul 21, 2025

This PR needs some cleaning up. Will work on it separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants