Skip to content

Commit b10a051

Browse files
committed
fix: add check for disabled gitLeaks config
1 parent 8b16d11 commit b10a051

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ const exec = async (req: any, action: Action): Promise<Action> => {
123123
return action;
124124
}
125125

126+
if (!config.enabled) {
127+
console.log('gitleaks is disabled, skipping');
128+
action.addStep(step);
129+
return action;
130+
}
131+
126132
const { commitFrom, commitTo } = action;
127133
const workingDir = `${action.proxyGitPath}/${action.repoName}`;
128134
console.log(`Scanning range with gitleaks: ${commitFrom}:${commitTo}`, workingDir);

test/processors/gitLeaks.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,17 @@ describe('gitleaks', () => {
6969
expect(stepSpy.calledWith('failed setup gitleaks, please contact an administrator\n')).to.be.true;
7070
expect(errorStub.calledWith('failed to get gitleaks config, please fix the error:')).to.be.true;
7171
});
72+
73+
it('should skip scanning when plugin is disabled', async () => {
74+
stubs.getAPIs.returns({ gitleaks: { enabled: false } });
75+
76+
const result = await exec(req, action);
77+
78+
expect(result.error).to.be.false;
79+
expect(result.steps).to.have.lengthOf(1);
80+
expect(result.steps[0].error).to.be.false;
81+
expect(logStub.calledWith('gitleaks is disabled, skipping')).to.be.true;
82+
});
83+
7284
});
7385
});

0 commit comments

Comments
 (0)