-
Notifications
You must be signed in to change notification settings - Fork 5
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
SHA-256 hash support for unverified upstream sources #147
base: main
Are you sure you want to change the base?
Conversation
fb5e905
to
6b33125
Compare
1a76c05
to
3ec6eb1
Compare
3ec6eb1
to
a181955
Compare
@@ -42,3 +42,12 @@ func TestMatchTarballSignature(t *testing.T) { | |||
t.Log("Test tarball Signatue Match") | |||
testTarballSig(t, "matchTarball") | |||
} | |||
|
|||
func TestUpstreamSourcesSHA256Hash(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add a test case where sha256 check fails.
util/util.go
Outdated
func GenerateSha256Hash(filePath string) (string, error) { | ||
file, err := os.Open(filePath) | ||
if err != nil { | ||
return "", fmt.Errorf("errored with %s while creating file", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fnt.Errorf( "%sGenerateSha256Hash: errored out with '%s',
errPrefix, err )
@@ -0,0 +1,16 @@ | |||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename dir as upstream-hash-check-good
Also add a bad eext.yaml case under upstream-hash-check-bad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
present test case is checking for bad SHA256 hash
a181955
to
65476af
Compare
Unverified upstream sources (those with `skip-check: true`) are inherently risky as they lack a verification method. Any changes to these sources could go undetected. To address this, we now calculate and store the SHA-256 hash of unverified sources. This hash is added to the `eext.yaml` file under the `src-sha256-hash` field. During the `create-srpm` command, the hash in `eext.yaml` will be compared with the hash of the downloaded sources.
65476af
to
7ca1e86
Compare
@@ -131,6 +131,7 @@ type UpstreamSrc struct { | |||
FullURL string `yaml:"full-url"` | |||
GitBundle GitBundle `yaml:"git"` | |||
Signature Signature `yaml:"signature"` | |||
Sha256 string `yaml:"Sha256"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we go with sha256
in the yaml file? All other fields follow lowercase convention.
@@ -50,6 +50,19 @@ func (bldr *srpmBuilder) getUpstreamSourceForOthers(upstreamSrcFromManifest mani | |||
} | |||
bldr.log("downloaded") | |||
|
|||
if upstreamSrcFromManifest.Sha256 != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic can be moved to a separate function. This will help you write test cases specifically for success/fail of signature check, instead of running create-srpm command
Unverified upstream sources (those with
skip-check: true
) are inherently risky as they lack a verification method. Any changes to these sources could go undetected. To address this, we now calculate and store the SHA-256 hash of unverified sources. This hash is added to theeext.yaml
file under thesrc-sha256-hash
field. During thecreate-srpm
command, the hash ineext.yaml
will be compared with the hash of the downloaded sources.