diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index f5d7a5c8d..8e186ca8c 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -32,9 +32,9 @@ jobs: run: | cd dist/macos for file in saf-*.pkg; do - prefix=${file%-*-*.pkg} - suffix=${file#saf-*-*-*} - mv "$file" "$prefix-$suffix" + prefix=${file%-*-*.pkg} + suffix=${file#saf-*-*-*} + mv "$file" "$prefix-$suffix" done - name: Upload SAF-CLI macOS Installer Artifact diff --git a/.github/workflows/build-windows-linux.yml b/.github/workflows/build-windows-linux.yml index 09373e0c4..aa44418d2 100644 --- a/.github/workflows/build-windows-linux.yml +++ b/.github/workflows/build-windows-linux.yml @@ -44,19 +44,19 @@ jobs: run: | cd saf/dist/win32 for file in saf-*.exe; do - prefix=${file%-*-*} # get prefix by removing frome end - suffix=${file#saf-*-*-} # get suffix by removing from start - mv "$file" "$prefix-$suffix" + prefix=${file%-*-*} # get prefix by removing from end + suffix=${file#saf-*-*-} # get suffix by removing from start + mv "$file" "$prefix-$suffix" done - name: Rename Debian Installers run: | cd saf/dist/deb for file in saf_*.deb; do - prefix=${file%.*-*.deb} - prefix_ver=${prefix#saf_} - suffix=${file#*_*_} - sudo mv "$file" "saf-$prefix_ver-$suffix" + prefix=${file%.*-*.deb} + prefix_ver=${prefix#saf_} + suffix=${file#*_*_} + sudo mv "$file" "saf-$prefix_ver-$suffix" done - name: Upload SAF-CLI Windows Build x64 Artifact diff --git a/.github/workflows/e2e-ci.yml b/.github/workflows/e2e-ci.yml index 940e6b9dd..46d3afd2d 100644 --- a/.github/workflows/e2e-ci.yml +++ b/.github/workflows/e2e-ci.yml @@ -12,23 +12,41 @@ jobs: strategy: fail-fast: true matrix: - platform: [ ubuntu-latest, macos-latest, windows-latest ] - runs-on: ${{ matrix.platform }} + platform: [ ubuntu, macos, windows ] + runs-on: ${{ matrix.platform }}-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Setup Node.js on ${{ matrix.platform }} - uses: actions/setup-node@v4 - with: - node-version: "22" - check-latest: true - cache: 'npm' + - name: Setup Node.js on ${{ matrix.platform }} + uses: actions/setup-node@v4 + with: + node-version: "22" + check-latest: true + cache: 'npm' - - name: Install dependencies on ${{ matrix.platform }} - run: npm ci + - name: Install dependencies on ${{ matrix.platform }} + run: npm ci + + - name: Install cinc-auditor/Compile/Run Tests on ${{ matrix.platform }} + if: ${{ matrix.platform == 'windows-latest' }} + shell: pwsh + run: | + Start-Process powershell -Verb RunAs + . { iwr -useb https://omnitruck.cinc.sh/install.ps1 } | iex; install -project cinc-auditor + $env:Path = $env:Path + ';C:\cinc-project\cinc-auditor\bin' + ';C:\cinc-project\cinc-auditor\embedded\bin' + cinc-auditor -v + npm run prepack + npm run test - - name: Prepack (compile) on ${{ matrix.platform }} - run: npm run prepack + - name: Install cinc-auditor/Compile/Run Tests on ${{ matrix.platform }} + if: ${{ matrix.platform == 'ubuntu-latest' || matrix.platform == 'macos-latest' }} + run: | + curl -L https://omnitruck.cinc.sh/install.sh | sudo bash -s -- -P cinc-auditor + npm run prepack + npm run test - - name: Run e2e tests on ${{ matrix.platform }} - run: npm run test + # - name: Prepack (compile) on ${{ matrix.platform }} + # run: npm run prepack + + # - name: Run e2e tests on ${{ matrix.platform }} + # run: npm run test diff --git a/src/commands/generate/delta.ts b/src/commands/generate/delta.ts index ec25996d6..2efe692ee 100644 --- a/src/commands/generate/delta.ts +++ b/src/commands/generate/delta.ts @@ -378,9 +378,7 @@ export default class GenerateDelta extends BaseCommand { // Get the directory name without the trailing "controls" directory // Here we are using the newly updated (mapped) controls // const profileDir = path.dirname(controlsDir) - // eslint-disable-next-line no-warning-comments - // TODO: normally it's 'inspec json ...' but vscode doesn't recognize my alias? - const inspecJsonFileNew = execSync(`inspec json '${mappedDir}'`, {encoding: 'utf8', maxBuffer: 50 * 1024 * 1024}) + const inspecJsonFileNew = execSync(`cinc-auditor json '${mappedDir}'`, {encoding: 'utf8', maxBuffer: 50 * 1024 * 1024}) // Replace existing profile (inputted JSON of source profile to be mapped) // Allow delta to take care of the rest diff --git a/test/commands/generate/delta.test.ts b/test/commands/generate/delta.test.ts index 20f667ba6..df1a7fddd 100644 --- a/test/commands/generate/delta.test.ts +++ b/test/commands/generate/delta.test.ts @@ -92,25 +92,24 @@ describe('Test generate delta command', () => { expect(fs.lstatSync((`${tmpobj.name}/delta.md`)).isFile()).to.be.true // skipcq: JS-0354 }) - // // NOTE: This test is failing in GitHub, but passes locally, commenting out for now - // // should process delta using the fuzzy logic - // it('should generate the correct number of controls using fuzzy logic to match and map controls', async () => { - // const {stdout} = await runCommand<{name: string}>(['generate delta', - // '-J', path.resolve('./test/sample_data/inspec/json/profile_and_controls/Windows_Server_2022_v1r3_mini-profile.json'), - // '-X', path.resolve('./test/sample_data/xccdf/stigs/Windows_Server_2022_V2R1_mini-sample-xccdf.xml'), - // '-o', `${tmpobj.name}`, - // '-M', - // '-c', path.resolve('./test/sample_data/inspec/json/profile_and_controls/windows_server_2022_v1r3_mini_controls/'), - // ]) + // should process delta using the fuzzy logic + it('should generate the correct number of controls using fuzzy logic to match and map controls', async () => { + const {stdout} = await runCommand<{name: string}>(['generate delta', + '-J', path.resolve('./test/sample_data/inspec/json/profile_and_controls/Windows_Server_2022_v1r3_mini-profile.json'), + '-X', path.resolve('./test/sample_data/xccdf/stigs/Windows_Server_2022_V2R1_mini-sample-xccdf.xml'), + '-o', `${tmpobj.name}`, + '-M', + '-c', path.resolve('./test/sample_data/inspec/json/profile_and_controls/windows_server_2022_v1r3_mini_controls/'), + ]) - // const output = stdout.split('\n') - // expect(output.includes('Total Controls Found on Delta Directory: 5')) - // expect(output.includes('Total Controls Found on XCCDF: 5')) - // expect(output.includes('Match Controls: 5')) - // expect(output.includes('["+","SV-254238"]')) - // expect(output.includes('["+","SV-254239"]')) - // expect(output.includes('["+","SV-254240"]')) - // expect(output.includes('["+","SV-254241"]')) - // expect(output.includes('["+","SV-254242"]')) - // }) + const output = stdout.split('\n') + expect(output.includes('Total Controls Found on Delta Directory: 5')) + expect(output.includes('Total Controls Found on XCCDF: 5')) + expect(output.includes('Match Controls: 5')) + expect(output.includes('["+","SV-254238"]')) + expect(output.includes('["+","SV-254239"]')) + expect(output.includes('["+","SV-254240"]')) + expect(output.includes('["+","SV-254241"]')) + expect(output.includes('["+","SV-254242"]')) + }) })