Skip to content

Do not display attestation-manifest and use short sha256 instead of full sha256 #32851

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

Merged
merged 10 commits into from
Dec 16, 2024
8 changes: 8 additions & 0 deletions modules/base/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ func ShortSha(sha1 string) string {
return TruncateString(sha1, 10)
}

// ShortSha256 takes 7-17 indexes of sha256 string as short sha256
func ShortSha256(sha256 string) string {
if utf8.RuneCountInString(sha256) < 17 {
return sha256
}
return string([]rune(sha256)[7:17])
}

// BasicAuthDecode decode basic auth string
func BasicAuthDecode(encoded string) (string, string, error) {
s, err := base64.StdEncoding.DecodeString(encoded)
Expand Down
1 change: 1 addition & 0 deletions modules/templates/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ func NewFuncMap() template.FuncMap {
// -----------------------------------------------------------------
// misc
"ShortSha": base.ShortSha,
"ShortSha256": base.ShortSha256,
"ActionContent2Commits": ActionContent2Commits,
"IsMultilineCommitMessage": isMultilineCommitMessage,
"CommentMustAsDiff": gitdiff.CommentMustAsDiff,
Expand Down
12 changes: 7 additions & 5 deletions templates/package/content/container.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@
</thead>
<tbody>
{{range .PackageDescriptor.Metadata.Manifests}}
<tr>
<td><a href="{{$.PackageDescriptor.PackageWebLink}}/{{PathEscape .Digest}}">{{.Digest}}</a></td>
<td>{{.Platform}}</td>
<td>{{FileSize .Size}}</td>
</tr>
{{if ne .Platform "unknown/unknown"}}
<tr>
<td><a class="ui sha label" href="{{$.PackageDescriptor.PackageWebLink}}/{{PathEscape .Digest}}">{{ShortSha256 .Digest}}</a></td>
<td>{{.Platform}}</td>
<td>{{FileSize .Size}}</td>
</tr>
{{end}}
{{end}}
</tbody>
</table>
Expand Down
Loading