Skip to content

Duplicate components in repeated scans #2768

Closed as not planned
Closed as not planned

Description

@maveritas

Current Behavior

When the same BOM file of the project is scanned repeatedly, components are duplicated. The first scan of the project is correct, components are not duplicated and have the same amount of BOM file, but the next scan of the same project, a new version of the project is added to DependencyTrack and all previous components from the previous version are cloned and N-1 (one component less from total amount in BOM file) components from new scan are added.

In most cases, this happens exactly when rescanning in a close time interval - 1-2 hours or less. If you wait, say, 5-6 hours, then the new version of the scan again gives the correct number of components. I tried increasing DELAY in the project cloning script, but it didn't change anything. I assume the problem is that DepTrack doesn't have time to process the previous scan command or its results and adds new ones.

I checked the problem on v4.7.1 and v4.8.0.
I attach logs from v4.7.1

Initially a BOM file with 138 components is given as input.
This screenshot shows the third scan of the project
138 components first scan (correct) + 137 second scan + 137 third scan. The BOM is the same as the 138 components.
Third scan
May 16, 2023, 17:24:55
image

All the logs show a strange time.

May 16, 2023, 17:24:55
image

First scan
May 16, 2023, 17:15:13
image

Second scan
May 16, 2023, 17:24:05
image

May 16, 2023, 17:24:05
image

After 5-10 hours of this scan, I run the scan again and the number of components becomes correct (138).
Fourth scan
May 17, 2023, 11:21:40
image

May 17, 2023, 11:21:40
image

Steps to Reproduce

  1. DepTrack receives the BOM file generated by cdxgen as input. The BOM file itself contains no duplicates and is correct with always the same number of components.
  2. DepTrack creates a new project, or if it already exists, creates a new version of that project and copies there the components/vulnerabilities from the previous version.
  3. After that it loads the components from the BOM file.
  4. In this step it must find NEW components compared to the previous version, but it ignores the components already loaded from the previous version and considers all the components loaded from the BOM file as NEW and just adds them, thus duplicating them with the previous version.

Expected Behavior

  1. DepTrack receives the BOM file generated by cdxgen as input. The BOM file itself contains no duplicates and is correct with always the same number of components.
  2. DepTrack creates a new project, or if it already exists, creates a new version of that project and copies there the components/vulnerabilities from the previous version.
  3. After that it loads the components from the BOM file.
    4. Finds NEW components compared to the previous version.
    5. Analyzes them.
    6. Adds NEW components to the previous actual components cloned from the previous scan.

The correct behavior happens only when the BOM file is loaded for the first time for scanning (a new project is created in DepTrack), or in 90% of cases when there is a long break between scans (about more than 5 hours)

Dependency-Track Version

4.7.x

Dependency-Track Distribution

Container Image

Database Server

PostgreSQL

Database Server Version

13.2

Browser

Google Chrome

Checklist

Activity

  1. added
    defect
    on May 17, 2023
  2. syalioune commented on May 18, 2023

    @syalioune
    Contributor

    Hello @maveritas

    How do you upload the SBOM to DT (i.e. custom script, jenkins plugins,...) ? And precisely why is there a project cloning on each uploads ?
    Note that the project cloning and bom upload tasks are processed in parallel by DT

    238900837-b5c32723-4587-433d-a573-1dac51993b53

    You can see above that :

    • The project cloning task started at 14:25:08 and ended at 14:25:10
    • The bom upload processing task started at 14:25:08 at 14:25:09

    if the bom upload processing task happens before the cloning task, component deduplication cannot be done that why you can see at 14:25:09 the message [BomProcessingUploadTask] Identified 137 new components.

    If you only need distinct versions on each upload, you can specify a new version and DT will create a new project. Components and vulnerabilities will be populated by SBOM and DT analyzers.
    If you also need audit history propagation, you can either :

  3. WDN2010 commented on Jun 22, 2023

    @WDN2010

    Hello @syalioune!
    We use a custom Python script to make API requests to the Dependency Track server. I have conducted additional tests, and it appears that the problem is caused by cloning the project and uploading the new SBOM file simultaneously.

    Here are the results of the test where the order of cloning and uploading the SBOM file was not checked:
    Script Log:

    Old project where we got number of components: 34f93a45-eb2c-41de-85b8-114cf72e2118
    Number of components on old version of project: 883
    Cloning dependency Track Project from UUID 34f93a45-eb2c-41de-85b8-114cf72e2118
    Searching for dependency track project (name: test, version: 36)
    External project UUID: bfe3701a-1a94-4409-ab41-8a85b18e842f
    Sending the BOM file to scan
    External scan token: 12548787-8d2c-4fc3-9a23-84ee2211c1ee
    0.8086838722229004 Scan processing: True
    1.1314713954925537 Scan processing: True
    Number of components: 462
    1.5331673622131348 Scan processing: True
    Number of components: 640
    1.9358117580413818 Scan processing: True
    Number of components: 862
    2.3470184803009033 Scan processing: True
    Number of components: 1120
    2.737821578979492 Scan processing: True
    Number of components: 1187
    3.1339833736419678 Scan processing: True
    Number of components: 1187
    3.5277748107910156 Scan processing: True
    Number of components: 1187
    3.9221744537353516 Scan processing: True
    Number of components: 1187
    4.322324514389038 Scan processing: True
    Number of components: 1187
    4.712267160415649 Scan processing: True
    Number of components: 1187
    5.112224817276001 Scan processing: True
    Number of components: 1187
    5.513568878173828 Scan processing: False
    Number of components: 1187
    Scan completed
    

    Dependency Track Log:

    2023-06-22 08:40:18,556 INFO [ProjectResource] Project test : 8 is being cloned by ***
    2023-06-22 08:40:18,557 INFO [CloneProjectTask] Cloning project: 34f93a45-eb2c-41de-85b8-114cf72e2118
    2023-06-22 08:40:19,188 INFO [BomUploadProcessingTask] Processing CycloneDX BOM uploaded to project: bfe3701a-1a94-4409-ab41-8a85b18e842f
    2023-06-22 08:40:20,556 INFO [CloneProjectTask] Cloned project: 34f93a45-eb2c-41de-85b8-114cf72e2118 to bfe3701a-1a94-4409-ab41-8a85b18e842f
    2023-06-22 08:40:21,023 INFO [BomUploadProcessingTask] Identified 304 new components
    2023-06-22 08:40:21,024 INFO [BomUploadProcessingTask] Processing CycloneDX dependency graph for project: bfe3701a-1a94-4409-ab41-8a85b18e842f
    2023-06-22 08:40:21,033 INFO [BomUploadProcessingTask] Processed 883 components and 0 services uploaded to project bfe3701a-1a94-4409-ab41-8a85b18e842f
    2023-06-22 08:40:21,033 INFO [RepositoryMetaAnalyzerTask] Performing component repository metadata analysis against 883 components
    2023-06-22 08:40:21,116 INFO [InternalAnalysisTask] Starting internal analysis task
    2023-06-22 08:40:21,116 INFO [InternalAnalysisTask] Analyzing 883 component(s)
    

    Note the line "Identified 304 new components." These are the additional components that were cloned.

    Here are the results of the test where the project was cloned first, and then the SBOM file was uploaded:

    Script Log:

    Old project where we got number of components: 34f93a45-eb2c-41de-85b8-114cf72e2118
    Number of components on old version of project: 883
    Cloning dependency Track Project from UUID 34f93a45-eb2c-41de-85b8-114cf72e2118
    Searching for dependency track project (name: test, version: 37)
    External project UUID: 9e70bebe-8b56-4ca6-ac0d-3d29e960beca
    Number of components on old version of project: 883
    Number of components right after cloning: 0
    Time: 0.30567097663879395 | Number of components: 0
    Time: 0.4281880855560303 | Number of components: 0
    Time: 0.5514423847198486 | Number of components: 49
    Time: 0.7018337249755859 | Number of components: 133
    Time: 0.8623523712158203 | Number of components: 221
    Time: 1.0220527648925781 | Number of components: 305
    Time: 1.1864674091339111 | Number of components: 399
    Time: 1.3549928665161133 | Number of components: 480
    Time: 1.514697790145874 | Number of components: 552
    Time: 1.6854932308197021 | Number of components: 629
    Time: 1.8594305515289307 | Number of components: 708
    Time: 2.019526720046997 | Number of components: 773
    Time: 2.186704397201538 | Number of components: 840
    Time: 2.355095148086548 | Number of components: 883
    Sending the BOM file to scan
    External scan token: c14b93f0-8684-492d-807a-cee9ad8ee4d7
    6.765676975250244 Scan processing: True
    7.088994026184082 Scan processing: True
    Number of components: 883
    7.4804463386535645 Scan processing: True
    Number of components: 883
    7.871082782745361 Scan processing: True
    Number of components: 883
    8.277280569076538 Scan processing: True
    Number of components: 883
    8.69338607788086 Scan processing: True
    Number of components: 883
    9.083720922470093 Scan processing: True
    Number of components: 883
    9.493598937988281 Scan processing: True
    Number of components: 883
    9.881703853607178 Scan processing: False
    Number of components: 883
    Scan completed
    

    Dependency Track Log:

    2023-06-22 09:03:05,922 INFO [ProjectResource] Project test : 8 is being cloned by ***
    2023-06-22 09:03:05,923 INFO [CloneProjectTask] Cloning project: 34f93a45-eb2c-41de-85b8-114cf72e2118
    2023-06-22 09:03:08,077 INFO [CloneProjectTask] Cloned project: 34f93a45-eb2c-41de-85b8-114cf72e2118 to 9e70bebe-8b56-4ca6-ac0d-3d29e960beca
    2023-06-22 09:03:12,516 INFO [BomUploadProcessingTask] Processing CycloneDX BOM uploaded to project: 9e70bebe-8b56-4ca6-ac0d-3d29e960beca
    2023-06-22 09:03:14,142 INFO [BomUploadProcessingTask] Identified 0 new components
    2023-06-22 09:03:14,142 INFO [BomUploadProcessingTask] Processing CycloneDX dependency graph for project: 9e70bebe-8b56-4ca6-ac0d-3d29e960beca
    2023-06-22 09:03:14,151 INFO [BomUploadProcessingTask] Processed 883 components and 0 services uploaded to project 9e70bebe-8b56-4ca6-ac0d-3d29e960beca
    2023-06-22 09:03:14,151 INFO [RepositoryMetaAnalyzerTask] Performing component repository metadata analysis against 883 components
    2023-06-22 09:03:14,230 INFO [InternalAnalysisTask] Starting internal analysis task
    2023-06-22 09:03:14,230 INFO [InternalAnalysisTask] Analyzing 883 component(s)
    

    It worked perfectly! However, it appears that Dependency Track should not combine these two processes to avoid cluttering the results.

  4. syalioune commented on Aug 20, 2023

    @syalioune
    Contributor

    Fantastic, I guess this issue can be closed then. #2842 would track the API enhancement.

  5. added
    duplicate
    and removed
    defect
    on Jan 14, 2024
  6. github-actions commented on Feb 14, 2024

    @github-actions
    Contributor

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  7. locked as resolved and limited conversation to collaborators on Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions