@leed-ai/git-gateway-worker 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +49 -2
- package/dist/audit/audit-recorder.d.ts +2 -0
- package/dist/audit/audit-recorder.js +53 -0
- package/dist/audit/audit-recorder.js.map +1 -0
- package/dist/audit/push-report.d.ts +13 -0
- package/dist/audit/push-report.js +66 -0
- package/dist/audit/push-report.js.map +1 -0
- package/dist/audit-recorder-K1Ns3tfC.d.ts +31 -0
- package/dist/auth/authenticate.d.ts +14 -0
- package/dist/auth/authenticate.js +59 -0
- package/dist/auth/authenticate.js.map +1 -0
- package/dist/auth/authorize.d.ts +12 -0
- package/dist/auth/authorize.js +57 -0
- package/dist/auth/authorize.js.map +1 -0
- package/dist/auth/read-token-auth.d.ts +60 -0
- package/dist/auth/read-token-auth.js +83 -0
- package/dist/auth/read-token-auth.js.map +1 -0
- package/dist/cache/decision-cache.d.ts +2 -0
- package/dist/cache/decision-cache.js +45 -0
- package/dist/cache/decision-cache.js.map +1 -0
- package/dist/commit-workflow-schemas-BWlg7bZR.d.ts +95 -0
- package/dist/decision-cache-87U32iSj.d.ts +24 -0
- package/dist/gateway-app.d.ts +69 -0
- package/dist/gateway-app.js +80 -0
- package/dist/gateway-app.js.map +1 -0
- package/dist/gateway-context-Boh9I0mk.d.ts +54 -0
- package/dist/gateway-env-DnsBU4Pq.d.ts +40 -0
- package/dist/gateway-worker.d.ts +13 -0
- package/dist/gateway-worker.js +22 -0
- package/dist/gateway-worker.js.map +1 -0
- package/dist/git-route-Spxi09Rm.d.ts +22 -0
- package/dist/health.d.ts +6 -0
- package/dist/health.js +16 -0
- package/dist/health.js.map +1 -0
- package/dist/logger-BZ1zyKLb.d.ts +27 -0
- package/dist/logging/logger.d.ts +2 -0
- package/dist/logging/logger.js +15 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/on-push-DTREOB__.d.ts +62 -0
- package/dist/policy/branch-policy.d.ts +24 -0
- package/dist/policy/branch-policy.js +125 -0
- package/dist/policy/branch-policy.js.map +1 -0
- package/dist/policy/enforce-branch-policy.d.ts +30 -0
- package/dist/policy/enforce-branch-policy.js +214 -0
- package/dist/policy/enforce-branch-policy.js.map +1 -0
- package/dist/policy/fast-forward.d.ts +32 -0
- package/dist/policy/fast-forward.js +95 -0
- package/dist/policy/fast-forward.js.map +1 -0
- package/dist/policy/ref-pattern.d.ts +7 -0
- package/dist/policy/ref-pattern.js +25 -0
- package/dist/policy/ref-pattern.js.map +1 -0
- package/dist/policy/rule-branch-policy.d.ts +17 -0
- package/dist/policy/rule-branch-policy.js +69 -0
- package/dist/policy/rule-branch-policy.js.map +1 -0
- package/dist/proxy/defer.d.ts +8 -0
- package/dist/proxy/defer.js +15 -0
- package/dist/proxy/defer.js.map +1 -0
- package/dist/proxy/forward-read.d.ts +11 -0
- package/dist/proxy/forward-read.js +53 -0
- package/dist/proxy/forward-read.js.map +1 -0
- package/dist/proxy/gateway-deps.d.ts +39 -0
- package/dist/proxy/gateway-deps.js +0 -0
- package/dist/proxy/gateway-env.d.ts +2 -0
- package/dist/proxy/gateway-env.js +0 -0
- package/dist/proxy/git-responses.d.ts +25 -0
- package/dist/proxy/git-responses.js +83 -0
- package/dist/proxy/git-responses.js.map +1 -0
- package/dist/proxy/git-route.d.ts +2 -0
- package/dist/proxy/git-route.js +34 -0
- package/dist/proxy/git-route.js.map +1 -0
- package/dist/proxy/push-events.d.ts +28 -0
- package/dist/proxy/push-events.js +65 -0
- package/dist/proxy/push-events.js.map +1 -0
- package/dist/proxy/push-guard.d.ts +43 -0
- package/dist/proxy/push-guard.js +81 -0
- package/dist/proxy/push-guard.js.map +1 -0
- package/dist/proxy/push-options.d.ts +16 -0
- package/dist/proxy/push-options.js +33 -0
- package/dist/proxy/push-options.js.map +1 -0
- package/dist/proxy/receive-pack.d.ts +17 -0
- package/dist/proxy/receive-pack.js +244 -0
- package/dist/proxy/receive-pack.js.map +1 -0
- package/dist/proxy/request-log.d.ts +13 -0
- package/dist/proxy/request-log.js +41 -0
- package/dist/proxy/request-log.js.map +1 -0
- package/dist/proxy/resolve-route.d.ts +9 -0
- package/dist/proxy/resolve-route.js +22 -0
- package/dist/proxy/resolve-route.js.map +1 -0
- package/dist/proxy/upstream-call.d.ts +23 -0
- package/dist/proxy/upstream-call.js +63 -0
- package/dist/proxy/upstream-call.js.map +1 -0
- package/dist/proxy/upstream.d.ts +2 -0
- package/dist/proxy/upstream.js +68 -0
- package/dist/proxy/upstream.js.map +1 -0
- package/dist/push-event-f-5TsFUY.d.ts +15 -0
- package/dist/push-policy/changed-paths.d.ts +26 -0
- package/dist/push-policy/changed-paths.js +117 -0
- package/dist/push-policy/changed-paths.js.map +1 -0
- package/dist/push-policy/pushed-objects.d.ts +30 -0
- package/dist/push-policy/pushed-objects.js +76 -0
- package/dist/push-policy/pushed-objects.js.map +1 -0
- package/dist/push-policy/run-push-policy.d.ts +35 -0
- package/dist/push-policy/run-push-policy.js +77 -0
- package/dist/push-policy/run-push-policy.js.map +1 -0
- package/dist/push-policy/tree-diff.d.ts +21 -0
- package/dist/push-policy/tree-diff.js +78 -0
- package/dist/push-policy/tree-diff.js.map +1 -0
- package/dist/push-policy/uncheckable.d.ts +14 -0
- package/dist/push-policy/uncheckable.js +25 -0
- package/dist/push-policy/uncheckable.js.map +1 -0
- package/dist/rpc/branch-methods.d.ts +16 -0
- package/dist/rpc/branch-methods.js +43 -0
- package/dist/rpc/branch-methods.js.map +1 -0
- package/dist/rpc/commit-attempt.d.ts +27 -0
- package/dist/rpc/commit-attempt.js +85 -0
- package/dist/rpc/commit-attempt.js.map +1 -0
- package/dist/rpc/commit-graph.d.ts +20 -0
- package/dist/rpc/commit-graph.js +38 -0
- package/dist/rpc/commit-graph.js.map +1 -0
- package/dist/rpc/commit-method.d.ts +13 -0
- package/dist/rpc/commit-method.js +30 -0
- package/dist/rpc/commit-method.js.map +1 -0
- package/dist/rpc/commit-source.d.ts +12 -0
- package/dist/rpc/commit-source.js +9 -0
- package/dist/rpc/commit-source.js.map +1 -0
- package/dist/rpc/gateway-context.d.ts +2 -0
- package/dist/rpc/gateway-context.js +30 -0
- package/dist/rpc/gateway-context.js.map +1 -0
- package/dist/rpc/gateway-rpc.d.ts +10 -0
- package/dist/rpc/gateway-rpc.js +48 -0
- package/dist/rpc/gateway-rpc.js.map +1 -0
- package/dist/rpc/gateway-service.d.ts +24 -0
- package/dist/rpc/gateway-service.js +63 -0
- package/dist/rpc/gateway-service.js.map +1 -0
- package/dist/rpc/history-page.d.ts +35 -0
- package/dist/rpc/history-page.js +122 -0
- package/dist/rpc/history-page.js.map +1 -0
- package/dist/rpc/lifecycle-methods.d.ts +12 -0
- package/dist/rpc/lifecycle-methods.js +39 -0
- package/dist/rpc/lifecycle-methods.js.map +1 -0
- package/dist/rpc/paint-down.d.ts +17 -0
- package/dist/rpc/paint-down.js +96 -0
- package/dist/rpc/paint-down.js.map +1 -0
- package/dist/rpc/promote-attempt.d.ts +21 -0
- package/dist/rpc/promote-attempt.js +55 -0
- package/dist/rpc/promote-attempt.js.map +1 -0
- package/dist/rpc/push-ref.d.ts +21 -0
- package/dist/rpc/push-ref.js +47 -0
- package/dist/rpc/push-ref.js.map +1 -0
- package/dist/rpc/read-methods.d.ts +17 -0
- package/dist/rpc/read-methods.js +94 -0
- package/dist/rpc/read-methods.js.map +1 -0
- package/dist/rpc/read-token.d.ts +39 -0
- package/dist/rpc/read-token.js +107 -0
- package/dist/rpc/read-token.js.map +1 -0
- package/dist/rpc/repo-access.d.ts +36 -0
- package/dist/rpc/repo-access.js +75 -0
- package/dist/rpc/repo-access.js.map +1 -0
- package/dist/rpc/sync-attempt.d.ts +23 -0
- package/dist/rpc/sync-attempt.js +105 -0
- package/dist/rpc/sync-attempt.js.map +1 -0
- package/dist/sync-workflow-schemas-DCNmNE5-.d.ts +57 -0
- package/dist/upstream-DvqMCj5N.d.ts +15 -0
- package/dist/workflow-starter-BqhwX6oA.d.ts +45 -0
- package/dist/workflows/commit-workflow-schemas.d.ts +2 -0
- package/dist/workflows/commit-workflow-schemas.js +84 -0
- package/dist/workflows/commit-workflow-schemas.js.map +1 -0
- package/dist/workflows/commit-workflow.d.ts +16 -0
- package/dist/workflows/commit-workflow.js +22 -0
- package/dist/workflows/commit-workflow.js.map +1 -0
- package/dist/workflows/on-push.d.ts +2 -0
- package/dist/workflows/on-push.js +90 -0
- package/dist/workflows/on-push.js.map +1 -0
- package/dist/workflows/push-event.d.ts +2 -0
- package/dist/workflows/push-event.js +28 -0
- package/dist/workflows/push-event.js.map +1 -0
- package/dist/workflows/run-commit-workflow.d.ts +15 -0
- package/dist/workflows/run-commit-workflow.js +49 -0
- package/dist/workflows/run-commit-workflow.js.map +1 -0
- package/dist/workflows/run-sync-workflow.d.ts +14 -0
- package/dist/workflows/run-sync-workflow.js +67 -0
- package/dist/workflows/run-sync-workflow.js.map +1 -0
- package/dist/workflows/step-errors.d.ts +15 -0
- package/dist/workflows/step-errors.js +24 -0
- package/dist/workflows/step-errors.js.map +1 -0
- package/dist/workflows/step-runner.d.ts +31 -0
- package/dist/workflows/step-runner.js +6 -0
- package/dist/workflows/step-runner.js.map +1 -0
- package/dist/workflows/sync-branch-workflow.d.ts +15 -0
- package/dist/workflows/sync-branch-workflow.js +21 -0
- package/dist/workflows/sync-branch-workflow.js.map +1 -0
- package/dist/workflows/sync-workflow-schemas.d.ts +2 -0
- package/dist/workflows/sync-workflow-schemas.js +104 -0
- package/dist/workflows/sync-workflow-schemas.js.map +1 -0
- package/dist/workflows/workflow-instance-id.d.ts +12 -0
- package/dist/workflows/workflow-instance-id.js +33 -0
- package/dist/workflows/workflow-instance-id.js.map +1 -0
- package/dist/workflows/workflow-runtime.d.ts +7 -0
- package/dist/workflows/workflow-runtime.js +11 -0
- package/dist/workflows/workflow-runtime.js.map +1 -0
- package/dist/workflows/workflow-starter.d.ts +2 -0
- package/dist/workflows/workflow-starter.js +40 -0
- package/dist/workflows/workflow-starter.js.map +1 -0
- package/package.json +381 -4
- package/src/audit/audit-recorder.ts +74 -0
- package/src/audit/push-report.ts +60 -0
- package/src/auth/authenticate.ts +68 -0
- package/src/auth/authorize.ts +57 -0
- package/src/auth/read-token-auth.ts +119 -0
- package/src/cache/decision-cache.ts +57 -0
- package/src/gateway-app.ts +147 -0
- package/src/gateway-worker.ts +32 -0
- package/src/health.ts +12 -0
- package/src/logging/logger.ts +40 -0
- package/src/policy/branch-policy.ts +119 -0
- package/src/policy/enforce-branch-policy.ts +213 -0
- package/src/policy/fast-forward.ts +136 -0
- package/src/policy/ref-pattern.ts +24 -0
- package/src/policy/rule-branch-policy.ts +76 -0
- package/src/proxy/defer.ts +18 -0
- package/src/proxy/forward-read.ts +52 -0
- package/src/proxy/gateway-deps.ts +43 -0
- package/src/proxy/gateway-env.ts +43 -0
- package/src/proxy/git-responses.ts +89 -0
- package/src/proxy/git-route.ts +49 -0
- package/src/proxy/push-events.ts +91 -0
- package/src/proxy/push-guard.ts +109 -0
- package/src/proxy/push-options.ts +38 -0
- package/src/proxy/receive-pack.ts +257 -0
- package/src/proxy/request-log.ts +44 -0
- package/src/proxy/resolve-route.ts +24 -0
- package/src/proxy/upstream-call.ts +71 -0
- package/src/proxy/upstream.ts +76 -0
- package/src/push-policy/changed-paths.ts +143 -0
- package/src/push-policy/pushed-objects.ts +88 -0
- package/src/push-policy/run-push-policy.ts +99 -0
- package/src/push-policy/tree-diff.ts +107 -0
- package/src/push-policy/uncheckable.ts +27 -0
- package/src/rpc/branch-methods.ts +57 -0
- package/src/rpc/commit-attempt.ts +87 -0
- package/src/rpc/commit-graph.ts +44 -0
- package/src/rpc/commit-method.ts +36 -0
- package/src/rpc/commit-source.ts +15 -0
- package/src/rpc/gateway-context.ts +77 -0
- package/src/rpc/gateway-rpc.ts +65 -0
- package/src/rpc/gateway-service.ts +85 -0
- package/src/rpc/history-page.ts +163 -0
- package/src/rpc/lifecycle-methods.ts +50 -0
- package/src/rpc/paint-down.ts +120 -0
- package/src/rpc/promote-attempt.ts +52 -0
- package/src/rpc/push-ref.ts +54 -0
- package/src/rpc/read-methods.ts +111 -0
- package/src/rpc/read-token.ts +135 -0
- package/src/rpc/repo-access.ts +112 -0
- package/src/rpc/sync-attempt.ts +84 -0
- package/src/workflows/commit-workflow-schemas.ts +95 -0
- package/src/workflows/commit-workflow.ts +39 -0
- package/src/workflows/on-push.ts +128 -0
- package/src/workflows/push-event.ts +41 -0
- package/src/workflows/run-commit-workflow.ts +45 -0
- package/src/workflows/run-sync-workflow.ts +52 -0
- package/src/workflows/step-errors.ts +26 -0
- package/src/workflows/step-runner.ts +36 -0
- package/src/workflows/sync-branch-workflow.ts +40 -0
- package/src/workflows/sync-workflow-schemas.ts +122 -0
- package/src/workflows/workflow-instance-id.ts +26 -0
- package/src/workflows/workflow-runtime.ts +13 -0
- package/src/workflows/workflow-starter.ts +69 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import type { Authenticator, Authorizer } from '@leed-ai/git-gateway-contract/proxy/gateway-hooks';
|
|
3
|
+
import type { Principal, PrincipalInput } from '@leed-ai/git-gateway-contract/proxy/principal';
|
|
4
|
+
import { readCredential } from '@leed-ai/git-gateway-contract/proxy/request-credential';
|
|
5
|
+
import type { RepoName } from '@leed-ai/git-gateway-contract/schemas/names';
|
|
6
|
+
|
|
7
|
+
import { READ_TOKEN_PREFIX, ReadTokenSecret, verifyReadToken } from '../rpc/read-token.ts';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Every principal established from a read token has a subject starting with this prefix
|
|
11
|
+
* (`read-token:<jti>`). {@link withReadTokens} refuses any other authenticator's principal that
|
|
12
|
+
* claims it, so the subject cannot be forged by a deployment's own credentials.
|
|
13
|
+
*/
|
|
14
|
+
export const READ_TOKEN_SUBJECT_PREFIX = 'read-token:';
|
|
15
|
+
|
|
16
|
+
/** The role a read token grants: read access to `repo` and nothing else. */
|
|
17
|
+
export function readTokenRole(repo: string): string {
|
|
18
|
+
return `read:${repo}`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Whether a principal was established from a read token. */
|
|
22
|
+
export function isReadTokenPrincipal(principal: Pick<Principal, 'subject'>): boolean {
|
|
23
|
+
return principal.subject.startsWith(READ_TOKEN_SUBJECT_PREFIX);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Options of {@link ReadTokenAuthenticator}. */
|
|
27
|
+
export interface ReadTokenAuthenticatorOptions {
|
|
28
|
+
/** The HMAC key mintReadToken() signs with (the RPC service's `readTokenSecret`). */
|
|
29
|
+
readonly secret: string;
|
|
30
|
+
/** The clock tokens are checked against; default the system clock. */
|
|
31
|
+
readonly now?: () => Date;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Accepts the read tokens mintReadToken() issues (`ggr_…`), sent as the HTTP Basic password (any
|
|
36
|
+
* username) or as a Bearer token. A valid token becomes a principal with subject
|
|
37
|
+
* `read-token:<jti>`, the single role `read:<repo>` and `expiresAt` the token's expiry; anything
|
|
38
|
+
* else — another kind of credential, a forged, expired or malformed token — is null. It grants
|
|
39
|
+
* nothing by itself: pair it with {@link readTokenAuthorizer}, or use {@link withReadTokens}, which
|
|
40
|
+
* composes both with a deployment's own authenticator and authorizer.
|
|
41
|
+
*/
|
|
42
|
+
export class ReadTokenAuthenticator implements Authenticator {
|
|
43
|
+
readonly #secret: string;
|
|
44
|
+
readonly #now: () => Date;
|
|
45
|
+
|
|
46
|
+
constructor(options: ReadTokenAuthenticatorOptions) {
|
|
47
|
+
this.#secret = ReadTokenSecret.parse(options.secret);
|
|
48
|
+
this.#now = options.now ?? (() => new Date());
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async authenticate(request: Request): Promise<PrincipalInput | null> {
|
|
52
|
+
const credential = readCredential(request);
|
|
53
|
+
if (credential === null || !credential.secret.startsWith(READ_TOKEN_PREFIX)) return null;
|
|
54
|
+
const claims = await verifyReadToken(credential.secret, this.#secret, this.#now());
|
|
55
|
+
if (claims === null) return null;
|
|
56
|
+
return {
|
|
57
|
+
subject: `${READ_TOKEN_SUBJECT_PREFIX}${claims.jti}`,
|
|
58
|
+
name: null,
|
|
59
|
+
email: null,
|
|
60
|
+
roles: [readTokenRole(claims.repo)],
|
|
61
|
+
expiresAt: new Date(claims.exp * 1000).toISOString(),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* An authorizer for read-token principals: one may read (clone, fetch) the repository its token
|
|
68
|
+
* names and nothing else — never push, never another repository. Every other principal is
|
|
69
|
+
* decided by `fallback`. Use it only behind an authenticator that keeps other principals out of
|
|
70
|
+
* the `read-token:` subject namespace, as {@link withReadTokens} does.
|
|
71
|
+
*/
|
|
72
|
+
export function readTokenAuthorizer(fallback: Authorizer): Authorizer {
|
|
73
|
+
return {
|
|
74
|
+
authorize: async (principal: Principal, repo: RepoName, operation) => {
|
|
75
|
+
if (!isReadTokenPrincipal(principal)) return fallback.authorize(principal, repo, operation);
|
|
76
|
+
return (
|
|
77
|
+
operation === 'read' && principal.roles.length === 1 && principal.roles[0] === readTokenRole(repo)
|
|
78
|
+
);
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Options of {@link withReadTokens}. */
|
|
84
|
+
export interface WithReadTokensOptions extends ReadTokenAuthenticatorOptions {
|
|
85
|
+
/** The deployment's own authenticator, asked about every credential that is not a read token. */
|
|
86
|
+
readonly authenticator: Authenticator;
|
|
87
|
+
/** The deployment's own authorizer, asked about every principal not established from a read token. */
|
|
88
|
+
readonly authorizer: Authorizer;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Chains read tokens in front of a deployment's own authentication: a `ggr_` credential is checked
|
|
93
|
+
* by {@link ReadTokenAuthenticator} alone (an invalid one is refused, never handed on), any other
|
|
94
|
+
* credential goes to `authenticator`, whose principals may not use the `read-token:` subject
|
|
95
|
+
* prefix (such a principal is refused). The returned authorizer limits read-token principals to
|
|
96
|
+
* reading their one repository and leaves every other decision to `authorizer`. Pass both results
|
|
97
|
+
* to createGatewayApp, and the RPC service's `readTokenSecret` as `secret`, so a token from
|
|
98
|
+
* mintReadToken() clones `remoteUrl`.
|
|
99
|
+
*/
|
|
100
|
+
export function withReadTokens(options: WithReadTokensOptions): {
|
|
101
|
+
readonly authenticator: Authenticator;
|
|
102
|
+
readonly authorizer: Authorizer;
|
|
103
|
+
} {
|
|
104
|
+
const readTokens = new ReadTokenAuthenticator(options);
|
|
105
|
+
const own = options.authenticator;
|
|
106
|
+
return {
|
|
107
|
+
authenticator: {
|
|
108
|
+
authenticate: async (request) => {
|
|
109
|
+
const credential = readCredential(request);
|
|
110
|
+
if (credential?.secret.startsWith(READ_TOKEN_PREFIX) === true)
|
|
111
|
+
return readTokens.authenticate(request);
|
|
112
|
+
const principal = await own.authenticate(request);
|
|
113
|
+
if (principal === null) return null;
|
|
114
|
+
return principal.subject.startsWith(READ_TOKEN_SUBJECT_PREFIX) ? null : principal;
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
authorizer: readTokenAuthorizer(options.authorizer),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
|
|
3
|
+
interface Entry<V> {
|
|
4
|
+
readonly value: V;
|
|
5
|
+
readonly expiresAt: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** Options of a {@link DecisionCache}. */
|
|
9
|
+
export interface DecisionCacheOptions {
|
|
10
|
+
/** Most entries held; the least recently used is evicted first. 0 disables the cache. */
|
|
11
|
+
readonly maxEntries: number;
|
|
12
|
+
/** The clock, in milliseconds since the epoch; default `Date.now`. */
|
|
13
|
+
readonly now?: () => number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A small per-isolate cache of authentication and authorization decisions: each entry lives for
|
|
18
|
+
* its own TTL, and once full the least recently used entry is evicted. Keys are built by the
|
|
19
|
+
* caller from credential fingerprints and principal subjects — never from a credential itself.
|
|
20
|
+
*/
|
|
21
|
+
export class DecisionCache<V> {
|
|
22
|
+
readonly #entries = new Map<string, Entry<V>>();
|
|
23
|
+
readonly #maxEntries: number;
|
|
24
|
+
readonly #now: () => number;
|
|
25
|
+
|
|
26
|
+
constructor(options: DecisionCacheOptions) {
|
|
27
|
+
this.#maxEntries = options.maxEntries;
|
|
28
|
+
this.#now = options.now ?? Date.now;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** How many entries are held (expired ones included until they are next touched). */
|
|
32
|
+
get size(): number {
|
|
33
|
+
return this.#entries.size;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The live value for `key`, or undefined when absent or expired. */
|
|
37
|
+
get(key: string): V | undefined {
|
|
38
|
+
const entry = this.#entries.get(key);
|
|
39
|
+
if (entry === undefined) return undefined;
|
|
40
|
+
this.#entries.delete(key);
|
|
41
|
+
if (entry.expiresAt <= this.#now()) return undefined;
|
|
42
|
+
this.#entries.set(key, entry);
|
|
43
|
+
return entry.value;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Stores `value` for `ttlMs` milliseconds; a TTL of 0 or less stores nothing. */
|
|
47
|
+
set(key: string, value: V, ttlMs: number): void {
|
|
48
|
+
if (this.#maxEntries === 0 || ttlMs <= 0) return;
|
|
49
|
+
this.#entries.delete(key);
|
|
50
|
+
this.#entries.set(key, { value, expiresAt: this.#now() + ttlMs });
|
|
51
|
+
while (this.#entries.size > this.#maxEntries) {
|
|
52
|
+
const oldest = this.#entries.keys().next();
|
|
53
|
+
if (oldest.done === true) break;
|
|
54
|
+
this.#entries.delete(oldest.value);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import type {
|
|
3
|
+
AuditHook,
|
|
4
|
+
Authenticator,
|
|
5
|
+
Authorizer,
|
|
6
|
+
BranchPolicy,
|
|
7
|
+
PushPolicy,
|
|
8
|
+
} from '@leed-ai/git-gateway-contract/proxy/gateway-hooks';
|
|
9
|
+
import {
|
|
10
|
+
SmartHttpConfig,
|
|
11
|
+
type SmartHttpConfigInput,
|
|
12
|
+
} from '@leed-ai/git-gateway-contract/proxy/smart-http-config';
|
|
13
|
+
import { GatewayConfig, type GatewayConfigInput } from '@leed-ai/git-gateway-contract/schemas/gateway-config';
|
|
14
|
+
import type { StorageBackend } from '@leed-ai/git-gateway-contract/storage/storage-backend';
|
|
15
|
+
import { Hono } from 'hono';
|
|
16
|
+
|
|
17
|
+
import { AuditRecorder } from './audit/audit-recorder.ts';
|
|
18
|
+
import { authenticate } from './auth/authenticate.ts';
|
|
19
|
+
import { authorize } from './auth/authorize.ts';
|
|
20
|
+
import { DecisionCache } from './cache/decision-cache.ts';
|
|
21
|
+
import { DEFAULT_SERVICE_NAME, healthRoutes } from './health.ts';
|
|
22
|
+
import { silentLogger, type Logger } from './logging/logger.ts';
|
|
23
|
+
import { enforceBranchPolicy } from './policy/enforce-branch-policy.ts';
|
|
24
|
+
import { forwardRead } from './proxy/forward-read.ts';
|
|
25
|
+
import type { CachedDecision, GatewayDeps } from './proxy/gateway-deps.ts';
|
|
26
|
+
import type { GatewayEnv } from './proxy/gateway-env.ts';
|
|
27
|
+
import { textResponse } from './proxy/git-responses.ts';
|
|
28
|
+
import { receivePack } from './proxy/receive-pack.ts';
|
|
29
|
+
import { requestLog } from './proxy/request-log.ts';
|
|
30
|
+
import { resolveRoute } from './proxy/resolve-route.ts';
|
|
31
|
+
import type { UpstreamFetch } from './proxy/upstream.ts';
|
|
32
|
+
import { composeOnPush, type OnPushHook } from './workflows/on-push.ts';
|
|
33
|
+
import type { SyncBranchWorkflowParams } from './workflows/sync-workflow-schemas.ts';
|
|
34
|
+
import type { WorkflowStarter } from './workflows/workflow-starter.ts';
|
|
35
|
+
|
|
36
|
+
/** What a deployment composes the gateway from. */
|
|
37
|
+
export interface GatewayAppOptions {
|
|
38
|
+
/** Where the repositories are stored; mints the per-request upstream credential. */
|
|
39
|
+
readonly backend: StorageBackend;
|
|
40
|
+
/** Establishes who each request acts for (e.g. `JwtAuthenticator`). */
|
|
41
|
+
readonly authenticator: Authenticator;
|
|
42
|
+
/** Decides read and write access per principal and repository. */
|
|
43
|
+
readonly authorizer: Authorizer;
|
|
44
|
+
/** Decides which refs a push may update (e.g. `RuleBranchPolicy`). */
|
|
45
|
+
readonly branchPolicy: BranchPolicy;
|
|
46
|
+
/**
|
|
47
|
+
* The deployment's own rules over what a push changes (paths, file types, sizes), run after the
|
|
48
|
+
* branch policy on every push it allows; optional. When it asks for changed paths the gateway
|
|
49
|
+
* reads the pushed pack as it streams, bounded by `smartHttp.maxPushPolicy*` and
|
|
50
|
+
* `maxChangedPaths`.
|
|
51
|
+
*/
|
|
52
|
+
readonly pushPolicy?: PushPolicy;
|
|
53
|
+
/** Receives every authenticated operation; optional. */
|
|
54
|
+
readonly audit?: AuditHook;
|
|
55
|
+
/**
|
|
56
|
+
* Called after every push the storage host accepted through the proxy, with the refs its
|
|
57
|
+
* report-status marked "ok" (refused refs are left out; a push refused outright sends nothing),
|
|
58
|
+
* beside the sync rules, e.g. to send the event to a Queue. It runs after the response is under
|
|
59
|
+
* way (through `waitUntil`); a failure is logged, passed to {@link onPushError} and never
|
|
60
|
+
* changes the response.
|
|
61
|
+
*/
|
|
62
|
+
readonly onPush?: OnPushHook;
|
|
63
|
+
/** Receives onPush failures after they are logged, e.g. to count them; default: nothing more. */
|
|
64
|
+
readonly onPushError?: (error: unknown) => void;
|
|
65
|
+
/**
|
|
66
|
+
* The SyncBranchWorkflow binding `gateway.syncRules` start instances of after every accepted
|
|
67
|
+
* push to a rule's `from` branch; required when there are sync rules.
|
|
68
|
+
*/
|
|
69
|
+
readonly syncWorkflow?: WorkflowStarter<SyncBranchWorkflowParams>;
|
|
70
|
+
/** Structured logs; default none (pass `consoleLogger` in a Worker). */
|
|
71
|
+
readonly logger?: Logger;
|
|
72
|
+
/** Shared gateway settings; `authCacheSeconds` sets how long decisions are cached. */
|
|
73
|
+
readonly gateway?: GatewayConfigInput;
|
|
74
|
+
/** Smart-HTTP limits and the auth realm. */
|
|
75
|
+
readonly smartHttp?: SmartHttpConfigInput;
|
|
76
|
+
/** Name reported by GET /health; default "git-gateway". */
|
|
77
|
+
readonly serviceName?: string;
|
|
78
|
+
/** How requests reach the storage host; default the global `fetch`. */
|
|
79
|
+
readonly fetch?: UpstreamFetch;
|
|
80
|
+
/** The clock; default the system clock. */
|
|
81
|
+
readonly now?: () => Date;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The gateway as a Hono app: GET /health, and git smart HTTP at `/<repo>.git/info/refs`,
|
|
86
|
+
* `/<repo>.git/git-upload-pack` and `/<repo>.git/git-receive-pack`, each running route
|
|
87
|
+
* resolution → authentication → authorization (→ branch policy for pushes) as middleware before
|
|
88
|
+
* the request is proxied, streamed, to the storage host with a credential minted for it alone.
|
|
89
|
+
* Accepted pushes are delivered to the onPush hook and the sync rules after the response. Throws
|
|
90
|
+
* a TypeError when `gateway.syncRules` are set without a `syncWorkflow`. Create it once per
|
|
91
|
+
* isolate: it holds the decision cache.
|
|
92
|
+
*/
|
|
93
|
+
export function createGatewayApp(options: GatewayAppOptions): Hono<GatewayEnv> {
|
|
94
|
+
const logger = options.logger ?? silentLogger;
|
|
95
|
+
const now = options.now ?? (() => new Date());
|
|
96
|
+
const config = SmartHttpConfig.parse(options.smartHttp ?? {});
|
|
97
|
+
const gateway = GatewayConfig.parse(options.gateway ?? {});
|
|
98
|
+
const deps: GatewayDeps = {
|
|
99
|
+
backend: options.backend,
|
|
100
|
+
authenticator: options.authenticator,
|
|
101
|
+
authorizer: options.authorizer,
|
|
102
|
+
branchPolicy: options.branchPolicy,
|
|
103
|
+
pushPolicy: options.pushPolicy,
|
|
104
|
+
audit: new AuditRecorder(options.audit, logger, now),
|
|
105
|
+
logger,
|
|
106
|
+
cache: new DecisionCache<CachedDecision>({
|
|
107
|
+
maxEntries: config.decisionCacheEntries,
|
|
108
|
+
now: () => now().getTime(),
|
|
109
|
+
}),
|
|
110
|
+
config,
|
|
111
|
+
cacheTtlMs: gateway.authCacheSeconds * 1000,
|
|
112
|
+
fetch: options.fetch ?? (async (request) => fetch(request)),
|
|
113
|
+
now,
|
|
114
|
+
onPush: composeOnPush({
|
|
115
|
+
syncRules: gateway.syncRules,
|
|
116
|
+
syncWorkflow: options.syncWorkflow,
|
|
117
|
+
onPush: options.onPush,
|
|
118
|
+
}),
|
|
119
|
+
onPushError: options.onPushError ?? (() => undefined),
|
|
120
|
+
};
|
|
121
|
+
const app = new Hono<GatewayEnv>();
|
|
122
|
+
app.use('*', requestLog(logger, now));
|
|
123
|
+
app.route('/', healthRoutes(options.serviceName ?? DEFAULT_SERVICE_NAME));
|
|
124
|
+
const git = new Hono<GatewayEnv>();
|
|
125
|
+
const policy = enforceBranchPolicy(deps);
|
|
126
|
+
const read = forwardRead(deps);
|
|
127
|
+
const write = receivePack(deps);
|
|
128
|
+
git.use('*', resolveRoute(), authenticate(deps), authorize(deps));
|
|
129
|
+
git.use('*', async (context, next) =>
|
|
130
|
+
context.get('git').endpoint === 'receive-pack' ? policy(context, next) : next(),
|
|
131
|
+
);
|
|
132
|
+
git.all('*', async (context, next) =>
|
|
133
|
+
context.get('git').endpoint === 'receive-pack' ? write(context, next) : read(context, next),
|
|
134
|
+
);
|
|
135
|
+
app.route('/', git);
|
|
136
|
+
app.notFound(() => textResponse(404, 'Not found'));
|
|
137
|
+
app.onError((error, context) => {
|
|
138
|
+
logger.log({
|
|
139
|
+
level: 'error',
|
|
140
|
+
message: 'unhandled error',
|
|
141
|
+
requestId: context.get('requestId'),
|
|
142
|
+
error: error instanceof Error ? error.message : String(error),
|
|
143
|
+
});
|
|
144
|
+
return textResponse(500, 'Internal error', { 'X-Request-Id': context.get('requestId') });
|
|
145
|
+
});
|
|
146
|
+
return app;
|
|
147
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import type { Hono } from 'hono';
|
|
3
|
+
|
|
4
|
+
import { createGatewayApp, type GatewayAppOptions } from './gateway-app.ts';
|
|
5
|
+
import type { GatewayEnv } from './proxy/gateway-env.ts';
|
|
6
|
+
|
|
7
|
+
/** The fetch handler a Worker module exports. */
|
|
8
|
+
export interface GatewayWorker<Env> {
|
|
9
|
+
fetch(request: Request, env: Env, context: ExecutionContext): Promise<Response>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A Worker module's fetch handler that composes the gateway from its bindings: `setup` turns the
|
|
14
|
+
* environment into the app options (backend from `env.ARTIFACTS`, authenticator from JWKS
|
|
15
|
+
* settings, and so on). The app is built once per environment object, so the decision cache
|
|
16
|
+
* lives as long as the isolate.
|
|
17
|
+
*/
|
|
18
|
+
export function createGatewayWorker<Env extends object>(
|
|
19
|
+
setup: (env: Env) => GatewayAppOptions,
|
|
20
|
+
): GatewayWorker<Env> {
|
|
21
|
+
const apps = new WeakMap<Env, Hono<GatewayEnv>>();
|
|
22
|
+
return {
|
|
23
|
+
async fetch(request, env, context) {
|
|
24
|
+
let app = apps.get(env);
|
|
25
|
+
if (app === undefined) {
|
|
26
|
+
app = createGatewayApp(setup(env));
|
|
27
|
+
apps.set(env, app);
|
|
28
|
+
}
|
|
29
|
+
return app.fetch(request, env, context);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
package/src/health.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { Hono } from 'hono';
|
|
3
|
+
import { HealthResponse } from '@leed-ai/git-gateway-contract/health';
|
|
4
|
+
|
|
5
|
+
/** The service name reported when a deployment does not name itself. */
|
|
6
|
+
export const DEFAULT_SERVICE_NAME = 'git-gateway';
|
|
7
|
+
|
|
8
|
+
/** A Hono app serving `GET /health` for the given deployment name. */
|
|
9
|
+
export function healthRoutes(service: string = DEFAULT_SERVICE_NAME): Hono {
|
|
10
|
+
const body = HealthResponse.parse({ status: 'ok', service });
|
|
11
|
+
return new Hono().get('/health', (context) => context.json(body));
|
|
12
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
|
|
3
|
+
/** How serious a log entry is. */
|
|
4
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One structured log entry. Every entry the gateway writes carries the request id; none ever
|
|
8
|
+
* carries a credential, a header value or an upstream URL's query string.
|
|
9
|
+
*/
|
|
10
|
+
export interface LogEntry {
|
|
11
|
+
readonly level: LogLevel;
|
|
12
|
+
/** What happened, e.g. "request", "upstream failed", "audit hook failed". */
|
|
13
|
+
readonly message: string;
|
|
14
|
+
readonly requestId: string;
|
|
15
|
+
/** Further facts: repository, endpoint, principal subject, status, duration, reason. */
|
|
16
|
+
readonly [field: string]: string | number | boolean | null | readonly string[] | undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Where the gateway writes its structured logs. */
|
|
20
|
+
export interface Logger {
|
|
21
|
+
log(entry: LogEntry): void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** A logger that drops everything. */
|
|
25
|
+
export const silentLogger: Logger = { log: () => undefined };
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A logger that writes each entry as one JSON line to the console, which Workers Logs and
|
|
29
|
+
* `wrangler tail` collect.
|
|
30
|
+
*/
|
|
31
|
+
export const consoleLogger: Logger = {
|
|
32
|
+
log(entry) {
|
|
33
|
+
const line = JSON.stringify(entry);
|
|
34
|
+
// The console is the Workers runtime's log sink; this is the gateway's only use of it.
|
|
35
|
+
// oxlint-disable-next-line no-console
|
|
36
|
+
if (entry.level === 'error') console.error(line);
|
|
37
|
+
// oxlint-disable-next-line no-console
|
|
38
|
+
else console.log(line);
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { PolicyResult, type RefDecision } from '@leed-ai/git-gateway-contract/proxy/policy-result';
|
|
3
|
+
import { RefUpdate } from '@leed-ai/git-gateway-contract/schemas/ref-update';
|
|
4
|
+
import { ZERO_SHA } from '@leed-ai/git-gateway-contract/schemas/sha';
|
|
5
|
+
import type { ReceivePackRequest } from '@leed-ai/git-gateway-core/schemas/receive-pack';
|
|
6
|
+
|
|
7
|
+
import type { GatewayDeps } from '../proxy/gateway-deps.ts';
|
|
8
|
+
import type { PendingFastForward } from '../proxy/gateway-env.ts';
|
|
9
|
+
import type { RefRefusal } from '../proxy/git-responses.ts';
|
|
10
|
+
import type { GitRequest } from '../proxy/git-route.ts';
|
|
11
|
+
import { proveFastForward } from './fast-forward.ts';
|
|
12
|
+
|
|
13
|
+
/** The branch policy's verdict on a push before its pack is read. */
|
|
14
|
+
export interface PushVerdict {
|
|
15
|
+
/** Updates refused outright; when any is, nothing is forwarded. */
|
|
16
|
+
readonly refusals: readonly RefRefusal[];
|
|
17
|
+
/** Fast-forward-only updates whose new commit is not in storage yet: proven from the pack. */
|
|
18
|
+
readonly pending: readonly PendingFastForward[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** One line of at most 500 characters, as a report-status reason must be. */
|
|
22
|
+
export function reasonLine(text: string): string {
|
|
23
|
+
const line = text.replaceAll(/[\n\r\0]+/g, ' ').trim();
|
|
24
|
+
return (line === '' ? 'refused' : line).slice(0, 500);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const NOT_A_BRANCH = 'only branches (refs/heads/*) and tags (refs/tags/*) can be pushed through this gateway';
|
|
28
|
+
const UNVERIFIABLE = 'could not verify that the update is a fast-forward';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Runs the branch policy over every update of a push. Updates outside refs/heads/ and refs/tags/
|
|
32
|
+
* are refused before the policy is asked. A "fast-forward-only" decision allows a creation and
|
|
33
|
+
* refuses a deletion (no new commit can contain the old head); on an existing tag it is refused (moving a tag is never a fast-forward); on a branch whose new commit storage already
|
|
34
|
+
* has, ancestry is proven now; otherwise it is left pending, to be proven from the pack.
|
|
35
|
+
*/
|
|
36
|
+
export async function judgePush(
|
|
37
|
+
deps: GatewayDeps,
|
|
38
|
+
git: GitRequest,
|
|
39
|
+
principal: Parameters<GatewayDeps['branchPolicy']['check']>[0],
|
|
40
|
+
request: ReceivePackRequest,
|
|
41
|
+
): Promise<PushVerdict> {
|
|
42
|
+
const refusals: RefRefusal[] = [];
|
|
43
|
+
const updates: RefUpdate[] = [];
|
|
44
|
+
for (const command of request.commands) {
|
|
45
|
+
const parsed = RefUpdate.safeParse(command);
|
|
46
|
+
if (parsed.success) updates.push(parsed.data);
|
|
47
|
+
else refusals.push({ ref: command.ref, reason: NOT_A_BRANCH });
|
|
48
|
+
}
|
|
49
|
+
const result =
|
|
50
|
+
updates.length === 0
|
|
51
|
+
? { refs: [] }
|
|
52
|
+
: PolicyResult.parse(deps.branchPolicy.check(principal, git.repo, updates));
|
|
53
|
+
const decisions = new Map<string, RefDecision>(result.refs.map((decision) => [decision.ref, decision]));
|
|
54
|
+
const pending: PendingFastForward[] = [];
|
|
55
|
+
for (const update of updates) {
|
|
56
|
+
const decision = decisions.get(update.ref);
|
|
57
|
+
if (decision === undefined) {
|
|
58
|
+
refusals.push({ ref: update.ref, reason: 'the branch policy made no decision for this ref' });
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (decision.decision === 'allow') continue;
|
|
62
|
+
const reason = reasonLine(decision.reason);
|
|
63
|
+
if (decision.decision === 'deny') {
|
|
64
|
+
refusals.push({ ref: update.ref, reason });
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (update.newSha === ZERO_SHA) {
|
|
68
|
+
refusals.push({ ref: update.ref, reason });
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (update.oldSha === ZERO_SHA) continue;
|
|
72
|
+
if (update.ref.startsWith('refs/tags/')) {
|
|
73
|
+
refusals.push({ ref: update.ref, reason });
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
let stored: boolean;
|
|
77
|
+
try {
|
|
78
|
+
stored = (await deps.backend.readCommit(git.repo, update.newSha)) !== null;
|
|
79
|
+
} catch {
|
|
80
|
+
refusals.push({ ref: update.ref, reason: reasonLine(`${reason} (${UNVERIFIABLE})`) });
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (!stored) {
|
|
84
|
+
pending.push({ update, reason });
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const verdict = await proveFastForward(update.oldSha, update.newSha, {
|
|
88
|
+
repo: git.repo,
|
|
89
|
+
backend: deps.backend,
|
|
90
|
+
maxReads: deps.config.maxAncestryReads,
|
|
91
|
+
});
|
|
92
|
+
if (verdict === 'no') refusals.push({ ref: update.ref, reason });
|
|
93
|
+
if (verdict === 'unknown')
|
|
94
|
+
refusals.push({ ref: update.ref, reason: reasonLine(`${reason} (${UNVERIFIABLE})`) });
|
|
95
|
+
}
|
|
96
|
+
return { refusals, pending };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Proves pending fast-forwards from the scanned pack and storage; returns those that are not. */
|
|
100
|
+
export async function provePending(
|
|
101
|
+
deps: GatewayDeps,
|
|
102
|
+
git: GitRequest,
|
|
103
|
+
pending: readonly PendingFastForward[],
|
|
104
|
+
packCommits: ReadonlyMap<string, readonly string[]>,
|
|
105
|
+
): Promise<RefRefusal[]> {
|
|
106
|
+
const refusals: RefRefusal[] = [];
|
|
107
|
+
for (const { update, reason } of pending) {
|
|
108
|
+
const verdict = await proveFastForward(update.oldSha, update.newSha, {
|
|
109
|
+
repo: git.repo,
|
|
110
|
+
backend: deps.backend,
|
|
111
|
+
packCommits,
|
|
112
|
+
maxReads: deps.config.maxAncestryReads,
|
|
113
|
+
});
|
|
114
|
+
if (verdict === 'no') refusals.push({ ref: update.ref, reason });
|
|
115
|
+
if (verdict === 'unknown')
|
|
116
|
+
refusals.push({ ref: update.ref, reason: reasonLine(`${reason} (${UNVERIFIABLE})`) });
|
|
117
|
+
}
|
|
118
|
+
return refusals;
|
|
119
|
+
}
|