From fda6e3ce9478b80b17e5c2f934b021504fc33226 Mon Sep 17 00:00:00 2001 From: fabiovincenzi Date: Thu, 9 Apr 2026 17:46:47 +0200 Subject: [PATCH 1/6] fix: add missing utils/errors subpath export --- package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package.json b/package.json index c10721372..6fad88196 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,11 @@ "types": "./dist/src/ui/index.d.ts", "import": "./dist/src/ui/index.js", "require": "./dist/src/ui/index.js" + }, + "./utils/errors": { + "types": "./dist/src/utils/errors.d.ts", + "import": "./dist/src/utils/errors.js", + "require": "./dist/src/utils/errors.js" } }, "scripts": { From 8b606dfb6d9e76b9a85aae8231022f0c03bd23ea Mon Sep 17 00:00:00 2001 From: fabiovincenzi Date: Thu, 9 Apr 2026 17:47:13 +0200 Subject: [PATCH 2/6] fix: restrict tsconfig types to node --- packages/git-proxy-cli/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/git-proxy-cli/tsconfig.json b/packages/git-proxy-cli/tsconfig.json index 1c96fb30f..bfd212883 100644 --- a/packages/git-proxy-cli/tsconfig.json +++ b/packages/git-proxy-cli/tsconfig.json @@ -15,7 +15,8 @@ "allowSyntheticDefaultImports": true, "resolveJsonModule": true, "outDir": "./dist", - "rootDir": "." + "rootDir": ".", + "types": ["node"] }, "include": ["index.ts", "types.ts"], "exclude": [ From 064a9557d474172a7e223313e403a9bd4c28d9d7 Mon Sep 17 00:00:00 2001 From: fabiovincenzi Date: Thu, 9 Apr 2026 17:47:29 +0200 Subject: [PATCH 3/6] fix: update stale imports in CLI test utils --- packages/git-proxy-cli/test/testCliUtils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/git-proxy-cli/test/testCliUtils.ts b/packages/git-proxy-cli/test/testCliUtils.ts index dcfa12230..dba5c0417 100644 --- a/packages/git-proxy-cli/test/testCliUtils.ts +++ b/packages/git-proxy-cli/test/testCliUtils.ts @@ -20,13 +20,13 @@ import { exec } from 'child_process'; import { expect } from 'vitest'; import { Request } from 'express'; -import Proxy from '../../../src/proxy'; +import { Proxy } from '../../../src/proxy'; import { Action } from '../../../src/proxy/actions/Action'; import { Step } from '../../../src/proxy/actions/Step'; -import { exec as execProcessor } from '../../../src/proxy/processors/push-action/audit'; +import { exec as execProcessor } from '../../../src/proxy/processors/post-processor/audit'; import * as db from '../../../src/db'; import { Repo } from '../../../src/db/types'; -import service from '../../../src/service'; +import { Service as service } from '../../../src/service'; import { CommitData } from '../../../src/proxy/processors/types'; const execAsync = util.promisify(exec); From b9bf5c2d7d025fa895d6b4d50b2cb884daee6cc9 Mon Sep 17 00:00:00 2001 From: fabiovincenzi Date: Thu, 9 Apr 2026 17:47:53 +0200 Subject: [PATCH 4/6] fix: handle 403 and unhandled status codes in CLI --- packages/git-proxy-cli/index.ts | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/packages/git-proxy-cli/index.ts b/packages/git-proxy-cli/index.ts index 5f3b8e90c..bb1ec937a 100644 --- a/packages/git-proxy-cli/index.ts +++ b/packages/git-proxy-cli/index.ts @@ -229,12 +229,19 @@ async function authoriseGitPush(id: string) { if (isAxiosError(error) && error.response) { switch (error.response.status) { case 401: + case 403: console.error('Error: Authorise: Authentication required'); process.exitCode = 3; break; case 404: console.error(`Error: Authorise: ID: '${id}': Not Found`); process.exitCode = 4; + break; + default: + console.error( + `Error: Authorise: '${error.response.status}': ${error.response.data?.message || error.message}`, + ); + process.exitCode = 5; } } else { handleErrorAndLog(error, `Error: Authorise: '${id}'`); @@ -247,7 +254,7 @@ async function authoriseGitPush(id: string) { * Reject git push by ID * @param {string} id The ID of the git push to reject */ -async function rejectGitPush(id: string) { +async function rejectGitPush(id: string, reason: string) { if (!fs.existsSync(GIT_PROXY_COOKIE_FILE)) { console.error('Error: Reject: Authentication required'); process.exitCode = 1; @@ -263,7 +270,7 @@ async function rejectGitPush(id: string) { await axios.post( `${baseUrl}/api/v1/push/${id}/reject`, - {}, + { reason }, { headers: { Cookie: cookies }, }, @@ -274,12 +281,19 @@ async function rejectGitPush(id: string) { if (isAxiosError(error) && error.response) { switch (error.response.status) { case 401: + case 403: console.error('Error: Reject: Authentication required'); process.exitCode = 3; break; case 404: console.error(`Error: Reject: ID: '${id}': Not Found`); process.exitCode = 4; + break; + default: + console.error( + `Error: Reject: '${error.response.status}': ${error.response.data?.message || error.message}`, + ); + process.exitCode = 5; } } else { handleErrorAndLog(error, `Error: Reject: '${id}'`); @@ -319,12 +333,19 @@ async function cancelGitPush(id: string) { if (isAxiosError(error) && error.response) { switch (error.response.status) { case 401: + case 403: console.error('Error: Cancel: Authentication required'); process.exitCode = 3; break; case 404: console.error(`Error: Cancel: ID: '${id}': Not Found`); process.exitCode = 4; + break; + default: + console.error( + `Error: Cancel: '${error.response.status}': ${error.response.data?.message || error.message}`, + ); + process.exitCode = 5; } } else { handleErrorAndLog(error, `Error: Cancel: '${id}'`); @@ -423,6 +444,7 @@ async function createUser( if (isAxiosError(error) && error.response) { switch (error.response.status) { case 401: + case 403: console.error('Error: Create User: Authentication required'); process.exitCode = 3; break; @@ -563,9 +585,14 @@ yargs(hideBin(process.argv)) // eslint-disable-line @typescript-eslint/no-unused demandOption: true, type: 'string', }, + reason: { + describe: 'Reason for rejection', + type: 'string', + default: 'Rejected via GitProxy CLI', + }, }, handler(argv) { - rejectGitPush(argv.id); + rejectGitPush(argv.id, argv.reason); }, }) .command({ From 0e42bd480c7bbb99a5d319bb1731db832a10877a Mon Sep 17 00:00:00 2001 From: fabiovincenzi Date: Thu, 9 Apr 2026 17:48:42 +0200 Subject: [PATCH 5/6] fix: correct test config path and invalidate cache --- packages/git-proxy-cli/test/testCli.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/git-proxy-cli/test/testCli.test.ts b/packages/git-proxy-cli/test/testCli.test.ts index f139652bf..2be49a150 100644 --- a/packages/git-proxy-cli/test/testCli.test.ts +++ b/packages/git-proxy-cli/test/testCli.test.ts @@ -19,10 +19,14 @@ import path from 'path'; import { describe, it, beforeAll, afterAll } from 'vitest'; import { setConfigFile } from '../../../src/config/file'; +import { invalidateCache } from '../../../src/config'; import { SAMPLE_REPO } from '../../../src/proxy/processors/constants'; import { handleErrorAndLog } from '../../../src/utils/errors'; -setConfigFile(path.join(process.cwd(), 'test', 'testCli.proxy.config.json')); +setConfigFile( + path.join(process.cwd(), 'packages', 'git-proxy-cli', 'test', 'testCli.proxy.config.json'), +); +invalidateCache(); /* test constants */ // push ID which does not exist @@ -774,7 +778,7 @@ describe('test git-proxy-cli', function () { let expectedErrorMessages = null; await helper.runCli(cli, expectedExitCode, expectedMessages, expectedErrorMessages); - cli = `${CLI_PATH} reject --id ${pushId}`; + cli = `${CLI_PATH} reject --id ${pushId} --reason "Rejected via CLI test"`; expectedExitCode = 0; expectedMessages = [`Reject: ID: '${pushId}': OK`]; expectedErrorMessages = null; From 1b3e695072b747ecf982ae27c7e3abbedfcb7ada Mon Sep 17 00:00:00 2001 From: fabiovincenzi Date: Thu, 9 Apr 2026 17:49:02 +0200 Subject: [PATCH 6/6] fix: add attestationConfig to test proxy config --- packages/git-proxy-cli/test/testCli.proxy.config.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/git-proxy-cli/test/testCli.proxy.config.json b/packages/git-proxy-cli/test/testCli.proxy.config.json index f3a4aaa91..c4f9b57da 100644 --- a/packages/git-proxy-cli/test/testCli.proxy.config.json +++ b/packages/git-proxy-cli/test/testCli.proxy.config.json @@ -24,6 +24,14 @@ "enabled": false } ], + "attestationConfig": { + "questions": [ + { + "label": "Authorising via GitProxy CLI", + "required": true + } + ] + }, "authentication": [ { "type": "local",