Skip to content

Optimize file checksums calculation#5112

Merged
jeremylong merged 2 commits intodependency-check:mainfrom
koscejev:efficient-checksums
Dec 2, 2022
Merged

Optimize file checksums calculation#5112
jeremylong merged 2 commits intodependency-check:mainfrom
koscejev:efficient-checksums

Conversation

@koscejev
Copy link
Copy Markdown
Contributor

@koscejev koscejev commented Dec 2, 2022

Fixes Issue

I noticed checksums can be very slow to calculate for some larger files. One of the reasons is that the file is read 3 times - once per each checksum. (See Dependency.calculateChecksums(File).) This is easy to optimize by reading the file only once and calculating all 3 checksums together.

Description of Change

There are two commits:

  1. calculates (and caches) all supported checksums together for files
  2. (optional) removes dependency on commons-codec since I realized it's barely used and the methods that actually are used are already implemented in this Checksum class

Have test cases been added to cover the new functionality?

No new functionality added, and existing tests already cover the changed functionality.

checksums are frequently calculated together (see Dependency constructor)
so it makes sense to only read files once to calculate all checksums together
use the already existing checksum methods instead
@boring-cyborg boring-cyborg Bot added the utils changes to utils label Dec 2, 2022
@jeremylong
Copy link
Copy Markdown
Collaborator

CodeQL flagged the use of MD5 - this is not used as a security mechanism.

@jeremylong jeremylong added this to the 7.4.0 milestone Dec 2, 2022
@jeremylong jeremylong merged commit afb09b3 into dependency-check:main Dec 2, 2022
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Dec 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

utils changes to utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants