Skip to content

Commit

Permalink
Merge pull request #3570 from snyk/chore/change-project-name-source
Browse files Browse the repository at this point in the history
chore: change project name source
  • Loading branch information
YairZ101 authored Aug 15, 2022
2 parents f586333 + 8ef422d commit 88706d6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
5 changes: 1 addition & 4 deletions src/cli/commands/test/iac/v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function test(
options: Options & TestOptions,
): Promise<TestCommandResult> {
const testConfig = await prepareTestConfig(paths, options);
const { projectName, orgSettings } = testConfig;
const { orgSettings } = testConfig;

const testSpinner = buildSpinner({
options,
Expand All @@ -37,7 +37,6 @@ export async function test(
return buildOutput({
scanResult,
testSpinner,
projectName,
orgSettings,
options,
});
Expand All @@ -51,7 +50,6 @@ async function prepareTestConfig(
options: Options & TestOptions,
): Promise<TestConfig> {
const iacCachePath = pathLib.join(systemCachePath, 'iac');
const projectName = pathLib.basename(process.cwd());

const org = (options.org as string) || config.org;
const orgSettings = await getIacOrgSettings(org);
Expand All @@ -62,7 +60,6 @@ async function prepareTestConfig(
return {
paths,
iacCachePath,
projectName,
orgSettings,
userRulesBundlePath: config.IAC_BUNDLE_PATH,
userPolicyEnginePath: config.IAC_POLICY_ENGINE_PATH,
Expand Down
9 changes: 4 additions & 5 deletions src/lib/iac/test/v2/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ import { convertEngineToSarifResults } from './sarif';
import { CustomError, FormattedCustomError } from '../../../errors';
import { SnykIacTestError } from './errors';
import stripAnsi from 'strip-ansi';
import * as path from 'path';

export function buildOutput({
scanResult,
testSpinner,
projectName,
orgSettings,
options,
}: {
scanResult: TestOutput;
testSpinner?: Ora;
projectName: string;
orgSettings: IacOrgSettings;
options: any;
}): TestCommandResult {
Expand All @@ -40,7 +39,6 @@ export function buildOutput({

const { responseData, jsonData, sarifData } = buildTestCommandResultData({
scanResult,
projectName,
orgSettings,
options,
});
Expand All @@ -62,15 +60,16 @@ export function buildOutput({

function buildTestCommandResultData({
scanResult,
projectName,
orgSettings,
options,
}: {
scanResult: TestOutput;
projectName: string;
orgSettings: IacOrgSettings;
options: any;
}) {
const projectName =
scanResult.results?.metadata?.projectName ?? path.basename(process.cwd());

const jsonData = jsonStringifyLargeObject(
convertEngineToJsonResults({
results: scanResult,
Expand Down
5 changes: 5 additions & 0 deletions src/lib/iac/test/v2/scan/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ export interface SnykIacTestOutput {
export interface Results {
resources?: Resource[];
vulnerabilities?: Vulnerability[];
metadata?: Metadata;
}

export interface Metadata {
projectName: string;
}

export interface Vulnerability {
Expand Down
1 change: 0 additions & 1 deletion src/lib/iac/test/v2/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export interface TestConfig {
iacCachePath: string;
userRulesBundlePath?: string;
userPolicyEnginePath?: string;
projectName: string;
orgSettings: IacOrgSettings;
report: boolean;
severityThreshold?: SEVERITY;
Expand Down

0 comments on commit 88706d6

Please sign in to comment.