diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 18c256b0..c2a52a4a 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -26,12 +26,12 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Initialize CodeQL - uses: github/codeql-action/init@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6 + uses: github/codeql-action/init@ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd # v4.37.7 with: languages: javascript-typescript build-mode: none - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6 + uses: github/codeql-action/analyze@ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd # v4.37.7 with: category: '/language:javascript-typescript' diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 5e8e9e00..634d6b4b 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -45,6 +45,6 @@ jobs: retention-days: 5 - name: Upload to code-scanning - uses: github/codeql-action/upload-sarif@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6 + uses: github/codeql-action/upload-sarif@ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd # v4.37.7 with: sarif_file: results.sarif diff --git a/packages/cli/src/services/processComparisonFile.ts b/packages/cli/src/services/processComparisonFile.ts index ab0d9148..048bebf4 100644 --- a/packages/cli/src/services/processComparisonFile.ts +++ b/packages/cli/src/services/processComparisonFile.ts @@ -33,21 +33,33 @@ import type { * Result of processing comparison file */ export interface ProcessComparisonResult { + /** The scan result after processing the comparison file */ scanResult: ScanResult; + /** The environment variables from the comparison file */ envVariables: Record; + /** The file the comparison was made against */ comparedAgainst: string; - duplicatesFound: boolean; + /** The duplicate environment variables found in the comparison file */ dupsEnv: Duplicate[]; + /** The duplicate example variables found in the comparison file */ dupsEx: Duplicate[]; + /** The context of any fixes applied to the comparison file */ fix: FixContext; + /** The full contents of the example file, if it was found and read */ exampleFull?: Record | undefined; /** Basename of the example file `exampleFull` was read from. */ exampleFile?: string | undefined; + /** Uppercase keys found in the comparison file */ uppercaseWarnings?: UppercaseWarning[]; + /** Expiration warnings found in the comparison file */ expireWarnings?: ExpireWarning[]; + /** Inconsistent naming warnings found in the comparison file */ inconsistentNamingWarnings?: InconsistentNamingWarning[]; + /** Comment warnings found in the comparison file */ commentWarnings?: CommentWarning[]; + /** Drift warnings found in the comparison file */ driftWarnings?: DriftWarning[]; + /** Any error encountered while processing the comparison file */ error?: { message: string; shouldExit: boolean }; } @@ -65,7 +77,6 @@ export function processComparisonFile( ): ProcessComparisonResult { let envVariables: Record = {}; let comparedAgainst = ''; - let duplicatesFound = false; let dupsEnv: Duplicate[] = []; let dupsEx: Duplicate[] = []; let exampleFull: Record | undefined = undefined; @@ -155,7 +166,6 @@ export function processComparisonFile( const duplicateResults = checkDuplicates(compareFile, opts); dupsEnv = duplicateResults.dupsEnv; dupsEx = duplicateResults.dupsEx; - duplicatesFound = dupsEnv.length > 0 || dupsEx.length > 0; } if (opts.expireWarnings) { @@ -217,12 +227,14 @@ export function processComparisonFile( scanResult.missing = []; dupsEnv = []; dupsEx = []; - duplicatesFound = false; } } // Keep duplicates for output if not fixed - if (duplicatesFound && (!opts.fix || !fix.fixApplied)) { + if ( + (dupsEnv.length > 0 || dupsEx.length > 0) && + (!opts.fix || !fix.fixApplied) + ) { if (!scanResult.duplicates) scanResult.duplicates = {}; if (dupsEnv.length > 0) scanResult.duplicates.env = dupsEnv; if (dupsEx.length > 0) scanResult.duplicates.example = dupsEx; @@ -233,7 +245,6 @@ export function processComparisonFile( scanResult, envVariables, comparedAgainst, - duplicatesFound, dupsEnv, dupsEx, fix, @@ -255,7 +266,6 @@ export function processComparisonFile( scanResult, envVariables, comparedAgainst, - duplicatesFound, dupsEnv, dupsEx, fix, diff --git a/packages/cli/test/unit/services/processComparisonFile.test.ts b/packages/cli/test/unit/services/processComparisonFile.test.ts index df505a2c..85be982a 100644 --- a/packages/cli/test/unit/services/processComparisonFile.test.ts +++ b/packages/cli/test/unit/services/processComparisonFile.test.ts @@ -385,7 +385,6 @@ describe('processComparisonFile', () => { expect(result.dupsEnv).toHaveLength(0); expect(result.dupsEx).toHaveLength(0); - expect(result.duplicatesFound).toBe(false); }); it('sets duplicatesFound via dupsEx when only example file has duplicates (lines 109, 154)', () => { @@ -401,7 +400,6 @@ describe('processComparisonFile', () => { { ...baseOpts, allowDuplicates: false }, ); - expect(result.duplicatesFound).toBe(true); expect(result.dupsEnv).toHaveLength(0); expect(result.dupsEx).toHaveLength(1); // dupsEnv is empty → scanResult.duplicates.env NOT set (line 154 false branch)