diff --git a/README.md b/README.md index 2a9a0afed..6bacab68c 100644 --- a/README.md +++ b/README.md @@ -292,6 +292,7 @@ This format provides a clean, readable structure that is both human-friendly and - `--copy`: Additionally copy generated output to system clipboard - `--remote `: Process a remote Git repository - `--remote-branch `: Specify the remote branch name, tag, or commit hash (defaults to repository default branch) +- `--no-security-check`: Disable security check - `--verbose`: Enable verbose logging Examples: @@ -513,6 +514,15 @@ By default, Repomix's security check feature is enabled. You can disable it by s } ``` +Or using the `--no-security-check` command line option: + +```bash +repomix --no-security-check +``` + +> [!NOTE] +> Disabling security checks may expose sensitive information. Use this option with caution and only when necessary, such as when working with test files or documentation that contains example credentials. + ## 🤝 Contribution diff --git a/src/cli/actions/defaultAction.ts b/src/cli/actions/defaultAction.ts index 0ed8afc57..9f7bebd11 100644 --- a/src/cli/actions/defaultAction.ts +++ b/src/cli/actions/defaultAction.ts @@ -112,6 +112,9 @@ const buildCliConfig = (options: CliOptions): RepomixConfigCli => { if (options.style) { cliConfig.output = { ...cliConfig.output, style: options.style.toLowerCase() as RepomixOutputStyle }; } + if (options.securityCheck !== undefined) { + cliConfig.security = { enableSecurityCheck: options.securityCheck }; + } try { return repomixConfigCliSchema.parse(cliConfig); diff --git a/src/cli/cliRun.ts b/src/cli/cliRun.ts index 508f25073..ee026e778 100644 --- a/src/cli/cliRun.ts +++ b/src/cli/cliRun.ts @@ -25,6 +25,7 @@ export interface CliOptions extends OptionValues { global?: boolean; remote?: string; remoteBranch?: string; + securityCheck?: boolean; } export const run = async () => { @@ -49,6 +50,7 @@ export const run = async () => { '--remote-branch ', 'specify the remote branch name, tag, or commit hash (defaults to repository default branch)', ) + .option('--no-security-check', 'disable security check') .action((directory = '.', options: CliOptions = {}) => executeAction(directory, process.cwd(), options)); await program.parseAsync(process.argv); diff --git a/tests/cli/actions/defaultAction.test.ts b/tests/cli/actions/defaultAction.test.ts index 6dc77d441..ee575c5e6 100644 --- a/tests/cli/actions/defaultAction.test.ts +++ b/tests/cli/actions/defaultAction.test.ts @@ -123,4 +123,42 @@ describe('defaultAction', () => { await expect(runDefaultAction('.', process.cwd(), options)).rejects.toThrow('Test error'); }); + + describe('security check flag', () => { + it('should handle --no-security-check flag', async () => { + const options: CliOptions = { + securityCheck: false, + }; + + await runDefaultAction('.', process.cwd(), options); + + expect(configLoader.mergeConfigs).toHaveBeenCalledWith( + process.cwd(), + expect.anything(), + expect.objectContaining({ + security: { + enableSecurityCheck: false, + }, + }), + ); + }); + + it('should handle explicit --security-check flag', async () => { + const options: CliOptions = { + securityCheck: true, + }; + + await runDefaultAction('.', process.cwd(), options); + + expect(configLoader.mergeConfigs).toHaveBeenCalledWith( + process.cwd(), + expect.anything(), + expect.objectContaining({ + security: { + enableSecurityCheck: true, + }, + }), + ); + }); + }); }); diff --git a/tests/cli/cliRun.test.ts b/tests/cli/cliRun.test.ts index edb1d176a..e6a5892d4 100644 --- a/tests/cli/cliRun.test.ts +++ b/tests/cli/cliRun.test.ts @@ -115,4 +115,42 @@ describe('cliRun', () => { expect(defaultAction.runDefaultAction).not.toHaveBeenCalled(); }); }); + + describe('security check flag', () => { + test('should enable security check by default', async () => { + await executeAction('.', process.cwd(), {}); + + expect(defaultAction.runDefaultAction).toHaveBeenCalledWith( + '.', + process.cwd(), + expect.not.objectContaining({ + securityCheck: false, + }), + ); + }); + + test('should handle --no-security-check flag', async () => { + await executeAction('.', process.cwd(), { securityCheck: false }); + + expect(defaultAction.runDefaultAction).toHaveBeenCalledWith( + '.', + process.cwd(), + expect.objectContaining({ + securityCheck: false, + }), + ); + }); + + test('should handle explicit --security-check flag', async () => { + await executeAction('.', process.cwd(), { securityCheck: true }); + + expect(defaultAction.runDefaultAction).toHaveBeenCalledWith( + '.', + process.cwd(), + expect.objectContaining({ + securityCheck: true, + }), + ); + }); + }); });