Skip to content
Open
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
2 changes: 1 addition & 1 deletion .agents/skills/verify-lane-schedule/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ With every fact TRUE in the code, setting each fact FALSE in the model alone fai

## Coverage record

Sync commit: `9c7da84c0e2373bdcfed8399338081a0e6494990` (the last commit at which someone confirmed that the model describes this code; only `check.sh --record` moves it).
Sync commit: `71947bcc360301c223b108b1f6f17332199cdb38` (the last commit at which someone confirmed that the model describes this code; only `check.sh --record` moves it).

Every declaration in these files is covered:

Expand Down
3 changes: 2 additions & 1 deletion .agents/skills/verify-lane-schedule/model/fingerprints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ internal/githttp/hook.go:denyAuthorityDFConflict 3ad4a9b7cd317dbae7ebf368256b119
internal/githttp/hook.go:denyUnregisteredTargets 30226947720bb73dd56445e7227c26ae7647ccc04f4cfcaa61498129f47accca
internal/githttp/hook.go:enforceRefPolicy 2cd2cf6aea243221e8fe27280a6333695d4455a0304e7f536f7e8729dbb17a4d
internal/githttp/hook.go:enforceSyncClaimFence efb7b07e54bbb4008ac0cf53778c2ba690ad936051c103421aaf308b52e1cdf9
internal/githttp/hook.go:evalRefPolicy b232fd0a747ced157cec1bc4588e53bc13c54a39ff829f45108ae62c9601b5c8
internal/githttp/hook.go:evalRefPolicy fb4caa5bb76c4e050699f03b3790a91c1fb8191e09918134f2b73dc0a1ed7d8d
internal/githttp/hook.go:gitRefSegmentValid be11ac7ba983b399f85ec59e9ac524d9d95329fe7c774f011934bf97b1b26cf7
internal/githttp/hook.go:gitRefusalProbe.reaches 938ddcf9757e6b985bb3662f50b9fba53f51125d2d343ee8e0fff13ad530c065
internal/githttp/hook.go:hiddenOnRemote 91f396bdce763dd700bf642823435bfc3cec17f641d83f07af33f96ceacbe254
Expand All @@ -211,6 +211,7 @@ internal/githttp/hook.go:import_"fmt" 7b04a3fec895247a2e6af9e527c6e53593a4afd23c
internal/githttp/hook.go:import_"github.com/coder/openstorage/internal/auth" a6fc462be510789f5df8f2fd769b94612c4099fecfdd8be88a7a6b4ac6f12b03
internal/githttp/hook.go:import_"github.com/coder/openstorage/internal/blob" 7bbbe200b75dfad8f71f423fbf2bcd8ea49a5a98632059d22d77c4dc072e4026
internal/githttp/hook.go:import_"github.com/coder/openstorage/internal/envconfig" c05488126ab766402890a210f9a6b0cd8b6b3fb600c970209410bbafa6252d73
internal/githttp/hook.go:import_"github.com/coder/openstorage/internal/errtext" f1419e850961b9c71ddb7ebed6d98ca1a156fef54592d2fbe6bd0adbd42bff6b
internal/githttp/hook.go:import_"github.com/coder/openstorage/internal/gitlimit" 22f3f7dc1edac8d75858f1fe4ebcf09e7a520d8bdc31a4fb27a401f06cf288dd
internal/githttp/hook.go:import_"github.com/coder/openstorage/internal/meta" 4260dc2e40a07d98bb999c941803200e032f17530aab6c21fd272ac3fcd2fdb6
internal/githttp/hook.go:import_"github.com/coder/openstorage/internal/ref" 47381ca0e8ca453365ce8da40c529fc6f1fe3b6b1d26847f2298f92d1377d520
Expand Down
1 change: 1 addition & 0 deletions internal/errtext/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Bounds the request text that an error answer repeats, so that an answer stays sm
- `api` quotes a ref policy op that a ref, commit or merge write does not know (`unknown policy op "x" for <ref>`) [../api/handlers_write_refs.go:wrefPolicyCheck] [../api/handlers_write_commit.go:wcCheckRefPolicy] [../api/handlers_write_merge.go:server.wmCheckRefPolicy]
- `events` quotes a webhook URL or its host in a registration refusal, and cuts the parse error it adds after a URL that does not parse (`CheckRegistration`) [../events/guard.go:CheckRegistration]
- `githttp` cuts the error text of the git and LFS routes [../githttp/server.go:httpError] [../githttp/lfs.go:lfsError]
- `githttp` quotes a ref policy op that the update hook does not know, in the refusal that git shows the pusher (`evalRefPolicy`) [../githttp/hook.go:evalRefPolicy]

## Verification
- Run: `go test ./internal/errtext/... -tags=openstorage_viewcheck -count=1 -race -timeout=30m`
7 changes: 5 additions & 2 deletions internal/githttp/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/coder/openstorage/internal/auth"
"github.com/coder/openstorage/internal/blob"
"github.com/coder/openstorage/internal/envconfig"
"github.com/coder/openstorage/internal/errtext"
"github.com/coder/openstorage/internal/gitlimit"
"github.com/coder/openstorage/internal/meta"
"github.com/coder/openstorage/internal/ref"
Expand Down Expand Up @@ -2426,8 +2427,10 @@ func evalRefPolicy(ctx context.Context, repo, refName, old, new string, fullEval
needsSig = true
}
default:
// Unknown policy ops fail closed.
return refusef("unknown policy op %q for %s", op, refName)
// Unknown policy ops fail closed. The op is text of the
// pusher's token, as long as an environment entry allows, so
// the refusal quotes it cut (errtext.Quote), as the API does.
return refusef("unknown policy op %s for %s", errtext.Quote("", op), refName)
}
}
if needsAncestry {
Expand Down
40 changes: 40 additions & 0 deletions internal/githttp/hook_unknown_op_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package githttp

import (
"encoding/json"
"strings"
"testing"

"github.com/coder/openstorage/internal/ref"
)

// TestUnknownPolicyOpRefusalQuotedBounded: the update hook refuses a ref
// policy op that it does not know with a refusal that git shows the
// pusher, and quotes the op with errtext.Quote, so an op of any length
// makes a short line. The budget-free evaluation (fullEval off), which
// the reservation classifier runs, gives the same refusal.
func TestUnknownPolicyOpRefusalQuotedBounded(t *testing.T) {
const refName = "refs/heads/main"
newSHA := strings.Repeat("a", 40)
for _, tc := range []struct{ name, op, quoted string }{
{"a long op", strings.Repeat("<", 100_000), `"` + strings.Repeat("<", 256) + `…" (100000 bytes)`},
{"a short op", "no-fly", `"no-fly"`},
{"a short op with a quote", `no"fly`, `"no\"fly"`},
} {
t.Run(tc.name, func(t *testing.T) {
claim, err := json.Marshal([][]any{{"*", []string{tc.op}}})
if err != nil {
t.Fatal(err)
}
t.Setenv(EnvRefsPolicy, string(claim))
t.Setenv(EnvOps, "")
want := "unknown policy op " + tc.quoted + " for " + refName
for _, fullEval := range []bool{true, false} {
err := evalRefPolicy(t.Context(), "repo", refName, ref.ZeroSHA, newSHA, fullEval)
if err == nil || err.Error() != want || !ShownToPusher(err) {
t.Fatalf("evalRefPolicy(fullEval=%v) = %.300v; want a refusal %.300q", fullEval, err, want)
}
}
})
}
}
Loading