Skip to content

Commit b2d64d9

Browse files
committed
2 parents d4d9239 + 81daa80 commit b2d64d9

File tree

7 files changed

+1080
-99
lines changed

7 files changed

+1080
-99
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030

3131
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
3232
with:
33+
repository: jescalada/git-proxy-security-fixes
34+
token: ${{ secrets.PAT_TOKEN }}
3335
fetch-depth: 0
3436

3537
- name: Use Node.js ${{ matrix.node-version }}

src/proxy/processors/constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const BRANCH_PREFIX = 'refs/heads/';
2+
export const EMPTY_COMMIT_HASH = '0000000000000000000000000000000000000000';
3+
export const FLUSH_PACKET = '0000';
4+
export const PACK_SIGNATURE = 'PACK';
5+
export const PACKET_SIZE = 4;
6+
export const GIT_OBJECT_TYPE_COMMIT = 1;

src/proxy/processors/push-action/getDiff.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { Action, Step } from '../../actions';
22
import simpleGit from 'simple-git';
33

4+
import { EMPTY_COMMIT_HASH } from '../constants';
5+
46
const exec = async (req: any, action: Action): Promise<Action> => {
57
const step = new Step('diff');
68

@@ -11,11 +13,15 @@ const exec = async (req: any, action: Action): Promise<Action> => {
1113
let commitFrom = `4b825dc642cb6eb9a060e54bf8d69288fbee4904`;
1214

1315
if (!action.commitData || action.commitData.length === 0) {
14-
throw new Error('No commit data found');
16+
step.error = true;
17+
step.log('No commitData found');
18+
step.setError('Your push has been blocked because no commit data was found.');
19+
action.addStep(step);
20+
return action;
1521
}
1622

17-
if (action.commitFrom === '0000000000000000000000000000000000000000') {
18-
if (action.commitData[0].parent !== '0000000000000000000000000000000000000000') {
23+
if (action.commitFrom === EMPTY_COMMIT_HASH) {
24+
if (action.commitData[0].parent !== EMPTY_COMMIT_HASH) {
1925
commitFrom = `${action.commitData[action.commitData.length - 1].parent}`;
2026
}
2127
} else {

0 commit comments

Comments
 (0)