Skip to content

Better document a bad SHA256 invocation #3758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mcsaucy
Copy link

@mcsaucy mcsaucy commented Apr 19, 2025

What is the feature/fix?

** Describe the task and what is the goal for it. **

I'm trying to clean up improper uses of hash.Hash across Github. This code contains one such improper usage.

** Describe the bug and the solution. **

This code uses sha256.New().Sum instead of sha256.Sum256. The former appends sha256.Sum256(nil) to the input slice. See https://go.dev/play/p/vSW0U3Hq4qk for a demonstration of the differences.

SHA256 is used to generate identifiers that map server names to settings. I think these IDs have been persisted to external sources (setting.go mentions S3 buckets), so moving this to a good invocation is hard and probably not worth it. Instead, document the exact behavior of what's happening with the bad invocation, make it more obvious, and enshrine it within a helper function.

Does it has a breaking change?

Nope, deliberately so. I originally wanted to fix the invocation but it's not worth the effort to migrate to the new version considering no one has noticed this is broken.

How to use/test it?

Any use of the AWS provider's registry functionality.

Checklist

  • New coverage tests
  • Unit tests passing
  • E2E tests passing
  • E2E downgrade/update test passing
  • Documentation updated
  • No warnings or errors on Deepsource/Codecov

@mcsaucy mcsaucy force-pushed the push-syzpvswyyktz branch from 507ed55 to 0940085 Compare April 19, 2025 21:03
This code uses sha256.New().Sum instead of sha256.Sum256. See
https://go.dev/play/p/vSW0U3Hq4qk for a demonstration of the differences.

SHA256 is used to generate identifiers that map server names to settings. I
think these IDs have been persisted to external sources (setting.go mentions S3
buckets), so moving this to a good invocation is hard and probably not worth
it. Instead, document the exact behavior of what's happening with the bad
invocation, make it more obvious, and enshrine it within a helper function.
@mcsaucy mcsaucy force-pushed the push-syzpvswyyktz branch from 0940085 to 15b2a84 Compare April 19, 2025 21:03
Copy link

codecov bot commented Apr 19, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 35.88%. Comparing base (dcdca1f) to head (15b2a84).
Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
provider/aws/registries.go 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3758      +/-   ##
==========================================
+ Coverage   33.11%   35.88%   +2.77%     
==========================================
  Files         182      206      +24     
  Lines       20558    20642      +84     
==========================================
+ Hits         6807     7407     +600     
+ Misses      12604    11849     -755     
- Partials     1147     1386     +239     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant