Skip to content

Commit 034761e

Browse files
committed
comments
1 parent e18aa38 commit 034761e

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

src/utils/installPushProtectionHook.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,12 @@ export function installPushProtectionHook(workspacePath) {
105105
chmodSync(hookPath, 0o755);
106106
return { installed: true, hookPath, message: 'Hook updated' };
107107
}
108-
// There's a user-managed hook — append our block (no duplicate shebang)
108+
// There's a user-managed hook — append only for shell hooks to avoid breaking non-shell scripts
109+
const firstLine = existing.split('\n', 1)[0] || '';
110+
const isShellHook = firstLine.startsWith('#!') ? /\/(ba|z|k)?sh(\s|$)/.test(firstLine) : true;
111+
if (!isShellHook) {
112+
return { installed: false, hookPath, message: 'Existing pre-push hook is non-shell; cannot append CodeAnt block safely' };
113+
}
109114
const appended = existing.trimEnd() + '\n\n' + buildHookBlock() + '\n';
110115
writeFileSync(hookPath, appended, 'utf-8');
111116
chmodSync(hookPath, 0o755);

tests/secretsApiHelper.test.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,7 @@ describe('Secrets detection e2e tests', () => {
185185

186186
const result = await scanSecrets('staged-only');
187187

188-
const highConfidenceSecrets = result.secretsDetected.flatMap(f =>
189-
f.secrets.filter(s => s.confidence_score?.toUpperCase() === 'HIGH')
190-
);
191-
expect(highConfidenceSecrets).toHaveLength(0);
188+
expect(result.secretsDetected.flatMap(f => f.secrets)).toHaveLength(0);
192189
}, 30000);
193190

194191
it('no secrets in placeholder/example values', async () => {
@@ -205,10 +202,7 @@ describe('Secrets detection e2e tests', () => {
205202

206203
const result = await scanSecrets('staged-only');
207204

208-
const highConfidenceSecrets = result.secretsDetected.flatMap(f =>
209-
f.secrets.filter(s => s.confidence_score?.toUpperCase() === 'HIGH')
210-
);
211-
expect(highConfidenceSecrets).toHaveLength(0);
205+
expect(result.secretsDetected.flatMap(f => f.secrets)).toHaveLength(0);
212206
}, 30000);
213207
});
214208

@@ -377,7 +371,6 @@ describe('Secrets detection e2e tests', () => {
377371
const secret = fileResult.secrets[0];
378372
expect(secret).toHaveProperty('type');
379373
expect(secret).toHaveProperty('line_number');
380-
expect(secret).toHaveProperty('confidence_score');
381374
}, 30000);
382375

383376
it('returns empty secretsDetected for no-files scan', async () => {

0 commit comments

Comments
 (0)