Skip to content

Commit

Permalink
Update analyzer manager to v1.8.9 (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas authored Jul 31, 2024
1 parent fe24467 commit 13a9316
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 34 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ jobs:
# Fix 'nvm is not compatible with the npm config "prefix" option' error on macOS
run: unset npm_config_prefix
if: runner.os == 'macOS'
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.22.x
- name: Setup Python3
uses: actions/setup-python@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion src/main/scanLogic/scanRunners/analyzerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { LogUtils } from '../../log/logUtils';
export class AnalyzerManager {
private static readonly RELATIVE_DOWNLOAD_URL: string = '/xsc-gen-exe-analyzer-manager-local/v1';
private static readonly BINARY_NAME: string = 'analyzerManager';
public static readonly ANALYZER_MANAGER_VERSION: string = '1.8.8';
public static readonly ANALYZER_MANAGER_VERSION: string = '1.8.9';
public static readonly ANALYZER_MANAGER_PATH: string = Utils.addWinSuffixIfNeeded(
path.join(ScanUtils.getIssuesPath(), AnalyzerManager.BINARY_NAME, AnalyzerManager.BINARY_NAME)
);
Expand Down
5 changes: 5 additions & 0 deletions src/test/tests/integration/applicability.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { assert } from 'chai';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import {
ApplicabilityRunner,
Expand Down Expand Up @@ -31,6 +32,10 @@ describe('Applicability Integration Tests', async () => {

['npm', 'python'].forEach(async packageType => {
let directoryToScan: string = path.join(testDataRoot, packageType);
if (os.platform() === 'win32') {
// make the first char uppercase
directoryToScan = directoryToScan.charAt(0).toUpperCase() + directoryToScan.slice(1);
}
runScanAndAssert(packageType, directoryToScan, path.join(directoryToScan, 'expectedScanResponse.json'));
});

Expand Down
84 changes: 51 additions & 33 deletions src/test/tests/integration/secrets.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { assert } from 'chai';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';

import { AnalyzeScanRequest } from '../../../main/scanLogic/scanRunners/analyzerModels';
Expand Down Expand Up @@ -30,48 +31,65 @@ describe('Secrets Scan Integration Tests', async () => {
// Integration initialization
await integrationManager.initialize(testDataRoot);
runner = integrationManager.entitledJasRunnerFactory.createSecretsRunners()[0];

// Get expected partial result that the scan should contain
let dataPath: string = path.join(testDataRoot, 'expectedScanResponse.json');
expectedContent = JSON.parse(fs.readFileSync(dataPath, 'utf8').toString());
assert.isDefined(expectedContent, 'Failed to read expected SecretsScanResponse content from ' + dataPath);
// Run scan
// Try/Catch (with skip) should be removed after Secrets scan is released
response = await runner
.executeRequest(() => undefined, { roots: [testDataRoot] } as AnalyzeScanRequest)
.then(runResult => runner.convertResponse(runResult));
let directoryToScan: string = testDataRoot;
if (os.platform() === 'win32') {
// make the first char uppercase
directoryToScan = directoryToScan.charAt(0).toUpperCase() + directoryToScan.slice(1);
}
runScanAndAssert(directoryToScan);
});

it('Check response defined', () => {
assert.isDefined(response);
});
async function runScanAndAssert(directoryToScan: string) {
describe('Run tests in ' + directoryToScan + ' workspace for secrets issues', () => {
before(async () => {
// Get expected partial result that the scan should contain
let dataPath: string = path.join(directoryToScan, 'expectedScanResponse.json');
expectedContent = JSON.parse(fs.readFileSync(dataPath, 'utf8').toString());
assert.isDefined(expectedContent, 'Failed to read expected SecretsScanResponse content from ' + dataPath);
// Run scan
// Try/Catch (with skip) should be removed after Secrets scan is released
response = await runner
.executeRequest(() => undefined, { roots: [directoryToScan] } as AnalyzeScanRequest)
.then(runResult => runner.convertResponse(runResult));
});

it('Check response attributes defined', () => {
assert.isDefined(response.filesWithIssues);
});
it('Check response defined', () => {
assert.isDefined(response);
});

it('Check all expected files with issues detected', () =>
assertFileIssuesExist(testDataRoot, response.filesWithIssues, expectedContent.filesWithIssues));
it('Check response attributes defined', () => {
assert.isDefined(response.filesWithIssues);
});

it('Check all expected issues detected', () => assertIssuesExist(testDataRoot, response.filesWithIssues, expectedContent.filesWithIssues));
it('Check all expected files with issues detected', () =>
assertFileIssuesExist(directoryToScan, response.filesWithIssues, expectedContent.filesWithIssues));

it('Check all expected locations detected', () =>
assertIssuesLocationsExist(testDataRoot, response.filesWithIssues, expectedContent.filesWithIssues));
it('Check all expected issues detected', () =>
assertIssuesExist(directoryToScan, response.filesWithIssues, expectedContent.filesWithIssues));

it('Check calculateNumberOfTasks detected', () =>
assert.equal(
ScanManager.calculateNumberOfTasks(integrationManager.entitledJasRunnerFactory.createSecretsRunners(), new Map<PackageType, Uri[]>()),
1
));
it('Check all expected locations detected', () =>
assertIssuesLocationsExist(directoryToScan, response.filesWithIssues, expectedContent.filesWithIssues));

describe('Detected issues validations', () => {
it('Check rule-name', () => assertIssuesRuleNameExist(testDataRoot, response.filesWithIssues, expectedContent.filesWithIssues));
it('Check calculateNumberOfTasks detected', () =>
assert.equal(
ScanManager.calculateNumberOfTasks(
integrationManager.entitledJasRunnerFactory.createSecretsRunners(),
new Map<PackageType, Uri[]>()
),
1
));

it('Check rule full description', () =>
assertIssuesFullDescriptionExist(testDataRoot, response.filesWithIssues, expectedContent.filesWithIssues));
describe('Detected issues validations', () => {
it('Check rule-name', () => assertIssuesRuleNameExist(directoryToScan, response.filesWithIssues, expectedContent.filesWithIssues));

it('Check severity', () => assertIssuesSeverityExist(testDataRoot, response.filesWithIssues, expectedContent.filesWithIssues));
it('Check rule full description', () =>
assertIssuesFullDescriptionExist(directoryToScan, response.filesWithIssues, expectedContent.filesWithIssues));

it('Check snippet', () => assertIssuesLocationSnippetsExist(testDataRoot, response.filesWithIssues, expectedContent.filesWithIssues));
});
it('Check severity', () => assertIssuesSeverityExist(directoryToScan, response.filesWithIssues, expectedContent.filesWithIssues));

it('Check snippet', () =>
assertIssuesLocationSnippetsExist(directoryToScan, response.filesWithIssues, expectedContent.filesWithIssues));
});
});
}
});

0 comments on commit 13a9316

Please sign in to comment.