Skip to content

fix(fs): fix cache key generation to use UUID#8275

Merged
DmitriyLewen merged 5 commits intoaquasecurity:mainfrom
knqyf263:fix/fs_cache_key
Jan 23, 2025
Merged

fix(fs): fix cache key generation to use UUID#8275
DmitriyLewen merged 5 commits intoaquasecurity:mainfrom
knqyf263:fix/fs_cache_key

Conversation

@knqyf263
Copy link
Copy Markdown
Collaborator

@knqyf263 knqyf263 commented Jan 22, 2025

Overview

This PR modifies the cache key generation logic to use UUID with SHA256 hash. This ensures uniqueness and consistency in cache keys while maintaining a standardized SHA256 format.

Description

  • Modified calcCacheKey function to generate SHA256 hash from UUID
  • Updated test cases to use SetFakeUUID for consistent test results
  • Fixed test failures by ensuring each test case sets its own UUID

Related Issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).

The cache key generation logic has been modified to use UUID with SHA256 hash to ensure uniqueness and consistency in cache keys. This change helps prevent cache key collisions during parallel execution while maintaining a standardized SHA256 format.
@knqyf263 knqyf263 changed the title fix(cache): fix cache key generation to use UUID fix(fs): fix cache key generation to use UUID Jan 22, 2025
@knqyf263 knqyf263 self-assigned this Jan 22, 2025
Signed-off-by: knqyf263 <knqyf263@gmail.com>
Signed-off-by: knqyf263 <knqyf263@gmail.com>
Signed-off-by: knqyf263 <knqyf263@gmail.com>
@knqyf263 knqyf263 marked this pull request as ready for review January 22, 2025 17:33
Copy link
Copy Markdown
Contributor

@DmitriyLewen DmitriyLewen left a comment

Choose a reason for hiding this comment

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

LGTM.
Left small comment

Comment thread pkg/fanal/artifact/local/fs_test.go Outdated
Comment thread pkg/fanal/artifact/local/fs_test.go Outdated
Comment thread pkg/fanal/artifact/local/fs_test.go Outdated
This commit removes the fake UUID setup from the TestMixedConfigurationScan, TestJSONConfigScan, and TestYAMLConfigScan functions in fs_test.go.
@knqyf263 knqyf263 requested a review from DmitriyLewen January 23, 2025 07:01
@DmitriyLewen DmitriyLewen added this pull request to the merge queue Jan 23, 2025
Merged via the queue into aquasecurity:main with commit eafd810 Jan 23, 2025
@knqyf263 knqyf263 deleted the fix/fs_cache_key branch January 24, 2025 11:24
RingoDev referenced this pull request in RingoDev/trivy Feb 26, 2025
Signed-off-by: knqyf263 <knqyf263@gmail.com>
lebauce added a commit to DataDog/datadog-agent that referenced this pull request May 5, 2025
aquasecurity/trivy#8275 changed the
generation method for cache keys, that is used by the SBOM check
to send either a heartbeat or a full SBOM. As the key is now different
for every scan, we always send the full SBOM even if it's identical
to the previous computed one.

This commit computes the key based on the collected results
so that its stays identical if the list of components hasn't changed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(fs): improve cache key generation for parallel execution

3 participants