diff --git a/attestation/git/git.go b/attestation/git/git.go index 1ddb0155..e61a0af6 100644 --- a/attestation/git/git.go +++ b/attestation/git/git.go @@ -81,7 +81,7 @@ type Tag struct { type Attestor struct { GitTool string `json:"gittool"` GitBinPath string `json:"gitbinpath,omitempty"` - GitBinHash string `json:"gitbinhash,omitempty"` + GitBinHash cryptoutil.DigestSet `json:"gitbinhash,omitempty"` CommitHash string `json:"commithash"` Author string `json:"author"` AuthorEmail string `json:"authoremail"` diff --git a/attestation/git/git_bin.go b/attestation/git/git_bin.go index e2078347..c72043da 100644 --- a/attestation/git/git_bin.go +++ b/attestation/git/git_bin.go @@ -48,24 +48,23 @@ func GitGetBinPath() (string, error) { // GitGetBinHash retrieves a sha256 hash of the git binary that is located on the system. // The path is determined based on exec.LookPath(). -func GitGetBinHash(ctx *attestation.AttestationContext) (string, error) { +func GitGetBinHash(ctx *attestation.AttestationContext) (cryptoutil.DigestSet, error) { path, err := exec.LookPath("git") if err != nil { - return "", err + return cryptoutil.DigestSet{}, err } gitBinDigest, err := cryptoutil.CalculateDigestSetFromFile(path, ctx.Hashes()) fmt.Printf("%s", gitBinDigest) if err != nil { - return "", err + return cryptoutil.DigestSet{}, err } - digestMap, err := gitBinDigest.ToNameMap() if err != nil { - return "", err + return cryptoutil.DigestSet{}, err } - return fmt.Sprintf("sha256:%s", digestMap["sha256"]), nil + return gitBinDigest, nil } // GitGetStatus retrieves the status of staging and worktree diff --git a/schemagen/git.json b/schemagen/git.json index 54270a72..06f68704 100644 --- a/schemagen/git.json +++ b/schemagen/git.json @@ -11,7 +11,7 @@ "type": "string" }, "gitbinhash": { - "type": "string" + "$ref": "#/$defs/DigestSet" }, "commithash": { "type": "string"