Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions internal/ui/hygiene.templ
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,26 @@ templ HygienePage(v HygieneView) {
<span>All findings</span>
</a>
for _, k := range v.Kinds {
<a href={ templ.URL(hygieneURL(k.Kind, v.Team)) } class={ "tile", templ.KV("current", v.Kind == k.Kind), templ.KV("warn", k.Warn && k.Count > 0), templ.KV("zero", k.Count == 0) }>
<strong>{ itoa(k.Count) }</strong>
<span>{ k.Label }</span>
<small>{ k.Help }</small>
</a>
if k.Count > 0 || v.Kind == k.Kind {
<a href={ templ.URL(hygieneURL(k.Kind, v.Team)) } class={ "tile", templ.KV("current", v.Kind == k.Kind), templ.KV("warn", k.Warn && k.Count > 0), templ.KV("zero", k.Count == 0) }>
<strong>{ itoa(k.Count) }</strong>
<span>{ k.Label }</span>
<small>{ k.Help }</small>
</a>
}
}
</nav>
if clear := clearKinds(v.Kinds, v.Kind); len(clear) > 0 {
<p class="muted all-clear">
Also checked, nothing found:
for i, k := range clear {
if i > 0 {
{ ", " }
}
<span title={ k.Help }>{ k.Label }</span>
}
</p>
}
}
if len(v.DigestHints) > 0 {
<section class="panel">
Expand Down
331 changes: 193 additions & 138 deletions internal/ui/hygiene_templ.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/ui/integrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func TestHygieneTeamFilter(t *testing.T) {
if !strings.Contains(page, "ghcr.io/acme/payments:latest") || strings.Contains(page, "ghcr.io/acme/web:stable") {
t.Fatal("the team filter shows another team's images")
}
if !strings.Contains(page, `<option value="team-web">`) || !strings.Contains(page, `href="/hygiene?kind=retagged&amp;team=team-pay"`) {
if !strings.Contains(page, `<option value="team-web">`) || !strings.Contains(page, `href="/hygiene?team=team-pay"`) {
t.Fatal("no team choice, or the kinds lose the team")
}
}
10 changes: 7 additions & 3 deletions internal/ui/parts.templ
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ templ timeline(events []EventView, showService bool) {
@timeAgo(e.At)
<div class="ev">
<span class={ "kind", e.Type }>{ e.Label }</span>
<span class="what">{ e.Text }</span>
if showService && e.ServiceURL != "" {
<a class="where" href={ templ.URL(e.ServiceURL) }>{ e.Service }</a>
if rest, ok := leadingService(e, showService); ok {
<span class="what"><a class="u" href={ templ.URL(e.ServiceURL) }>{ e.Service }</a>{ rest }</span>
} else {
<span class="what">{ e.Text }</span>
if showService && e.ServiceURL != "" {
<a class="where" href={ templ.URL(e.ServiceURL) }>{ e.Service }</a>
}
}
if e.Ask != "" {
<button type="button" class="link ask-goli noprint" data-goli-ask={ e.Ask } title="Goli looks at everything else that changed around this time">Around this</button>
Expand Down
218 changes: 134 additions & 84 deletions internal/ui/parts_templ.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/ui/promotions.templ
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ templ PromotionsPage(v PromotionsView) {
<a class="button secondary gitops-pr noprint" href={ templ.URL("/services/" + p.Service + "/gitops/preview?" + previewQuery(pr.TargetID, pr.WorkloadID, p.Version, "/delivery")) } title={ "See the pull request in the repository " + pr.App + " deploys from before opening it" }>
{ "Open PR → " + p.To }
if len(p.PRs) > 1 {
{ " (" + pr.Target + ")" }
{ " (" + prPlace(p.PRs, pr) + ")" }
}
</a>
}
Expand Down
4 changes: 2 additions & 2 deletions internal/ui/promotions_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions internal/ui/prplace_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2026 The Goliash Authors
// SPDX-License-Identifier: AGPL-3.0-only

package ui

import "testing"

// Two pull requests on the same target are told apart by their application.
func TestPRPlace(t *testing.T) {
a := PromotePR{WorkloadID: "demo-staging/postgres", Target: "demo-staging", App: "identity-staging"}
b := PromotePR{WorkloadID: "demo-staging/shop-db", Target: "demo-staging", App: "webshop-staging"}
c := PromotePR{WorkloadID: "demo-prod/postgres", Target: "demo-prod", App: "identity-prod"}
prs := []PromotePR{a, b, c}
for _, tc := range []struct {
pr PromotePR
want string
}{{a, "identity-staging"}, {b, "webshop-staging"}, {c, "demo-prod"}} {
if got := prPlace(prs, tc.pr); got != tc.want {
t.Errorf("prPlace(%s) = %q, want %q", tc.pr.WorkloadID, got, tc.want)
}
}
}

func TestExploitedTail(t *testing.T) {
if got := exploitedTail(1, nil); got != " runs" {
t.Errorf("one: %q", got)
}
if got := exploitedTail(2, []string{"CVE-1", "CVE-2"}); got != " run, 2 past CISA's due date: CVE-1, CVE-2" {
t.Errorf("two: %q", got)
}
}

func TestLeadingService(t *testing.T) {
e := EventView{Service: "redis", ServiceURL: "/services/redis", Text: "redis @ prod: runs 7.2.4"}
if rest, ok := leadingService(e, true); !ok || rest != " @ prod: runs 7.2.4" {
t.Errorf("got %q %v", rest, ok)
}
e.Text = "redis-cache @ prod: runs 1"
if _, ok := leadingService(e, true); ok {
t.Error("a longer name is not the service")
}
if _, ok := leadingService(EventView{Service: "redis", ServiceURL: "/s", Text: "redis"}, false); ok {
t.Error("the service page does not link the service")
}
}
13 changes: 13 additions & 0 deletions internal/ui/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -1199,3 +1199,16 @@ func unmitigatedCount(r versions.VulnReport) int {
}
return n
}

// exploitedTail ends the brief's line on running exploited vulnerabilities: they run, and which are past
// CISA's due date.
func exploitedTail(n int, pastDue []string) string {
out := " runs"
if n != 1 {
out = " run"
}
if len(pastDue) > 0 {
out += ", " + itoa(len(pastDue)) + " past CISA's due date: " + strings.Join(pastDue, ", ")
}
return out
}
7 changes: 2 additions & 5 deletions internal/ui/security.templ
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ templ SecurityPage(v SecurityView) {
<div class="noprint"><a class="button secondary gitops-pr" href={ templ.URL(serviceURL(ex.Service.Name) + "/gitops/preview?" + previewQuery(pr.TargetID, pr.WorkloadID, ex.Target, "/security")) } title={ "See the pull request in the repository " + pr.App + " deploys from before opening it" }>
Open PR
if len(v.PRs[ex.Service.ID+"|"+ex.Environment.ID]) > 1 {
{ " (" + pr.Target + ")" }
{ " (" + prPlace(v.PRs[ex.Service.ID+"|"+ex.Environment.ID], pr) + ")" }
}
</a></div>
}
Expand Down Expand Up @@ -647,10 +647,7 @@ templ sinceYesterday(v SecurityView) {
}
if v.Brief.Exploited > 0 {
<li>
<a class="u" href="/security/vulns?kev=1">{ plural(v.Brief.Exploited, "vulnerability", "vulnerabilities") + " exploited in the wild" }</a> run
if len(v.Brief.PastDue) > 0 {
{ ", " + itoa(len(v.Brief.PastDue)) + " past CISA's due date: " + strings.Join(v.Brief.PastDue, ", ") }
}
<a class="u" href="/security/vulns?kev=1">{ plural(v.Brief.Exploited, "vulnerability", "vulnerabilities") + " exploited in the wild" }</a>{ exploitedTail(v.Brief.Exploited, v.Brief.PastDue) }
</li>
}
if len(v.Brief.Overdue) > 0 {
Expand Down
Loading
Loading