Skip to content

Commit

Permalink
Merge pull request #3450 from snyk/chore/remove-deprecated-scan-path-…
Browse files Browse the repository at this point in the history
…behaviour+test

feat: remove support for paths outside the current working directory
  • Loading branch information
francescomari committed Jul 11, 2022
2 parents 235e60c + 5ca35c1 commit 2037cb2
Show file tree
Hide file tree
Showing 27 changed files with 81 additions and 678 deletions.
4 changes: 3 additions & 1 deletion src/cli/commands/test/iac/index.ts
Expand Up @@ -48,8 +48,9 @@ export default async function(...args: MethodArgs): Promise<TestCommandResult> {
isNewIacOutputSupported,
});

const projectRoot = process.cwd();

printHeader({
paths,
options,
isNewIacOutputSupported,
});
Expand All @@ -67,6 +68,7 @@ export default async function(...args: MethodArgs): Promise<TestCommandResult> {
paths,
orgPublicId,
buildOciRegistry,
projectRoot,
);

return buildOutput({
Expand Down
15 changes: 4 additions & 11 deletions src/cli/commands/test/iac/local-execution/measurable-methods.ts
@@ -1,7 +1,6 @@
import { parseFiles } from './file-parser';
import { scanFiles } from './file-scanner';
import { formatScanResults as formatScanResultsV1 } from './process-results/v1/results-formatter';
import { formatScanResults as formatScanResultsV2 } from './process-results/v2/results-formatter';
import { formatScanResults } from './process-results/results-formatter';
import { trackUsage } from './usage-tracking';
import { cleanLocalCache, initLocalCache } from './local-cache';
import { applyCustomSeverities } from './org-settings/apply-custom-severities';
Expand Down Expand Up @@ -83,13 +82,8 @@ const measurableCleanLocalCache = performanceAnalyticsDecorator(
PerformanceAnalyticsKey.CacheCleanup,
);

const measurableFormatScanResultsV1 = performanceAnalyticsDecorator(
formatScanResultsV1,
PerformanceAnalyticsKey.ResultFormatting,
);

const measurableFormatScanResultsV2 = performanceAnalyticsDecorator(
formatScanResultsV2,
const measurableFormatScanResults = performanceAnalyticsDecorator(
formatScanResults,
PerformanceAnalyticsKey.ResultFormatting,
);

Expand All @@ -115,8 +109,7 @@ export {
measurableScanFiles as scanFiles,
measurableGetIacOrgSettings as getIacOrgSettings,
measurableApplyCustomSeverities as applyCustomSeverities,
measurableFormatScanResultsV1 as formatScanResultsV1,
measurableFormatScanResultsV2 as formatScanResultsV2,
measurableFormatScanResults as formatScanResultsV2,
measurableTrackUsage as trackUsage,
measurableCleanLocalCache as cleanLocalCache,
measurableLocalTest as localTest,
Expand Down
@@ -1,29 +1,26 @@
import config from '../../../../../../../lib/config';
import { makeRequest } from '../../../../../../../lib/request';
import { getAuthHeader } from '../../../../../../../lib/api-token';
import config from '../../../../../../lib/config';
import { makeRequest } from '../../../../../../lib/request';
import { getAuthHeader } from '../../../../../../lib/api-token';
import {
IacShareResultsFormat,
IaCTestFlags,
ShareResultsOutput,
} from '../../types';
import { convertIacResultToScanResult } from '../../../../../../../lib/iac/envelope-formatters';
import { Policy } from '../../../../../../../lib/policy/find-and-load-policy';
import { getInfo } from '../../../../../../../lib/project-metadata/target-builders/git';
import { GitTarget } from '../../../../../../../lib/ecosystems/types';
import { Contributor } from '../../../../../../../lib/types';
import * as analytics from '../../../../../../../lib/analytics';
import { getContributors } from '../../../../../../../lib/monitor/dev-count-analysis';
} from '../types';
import { convertIacResultToScanResult } from '../../../../../../lib/iac/envelope-formatters';
import { Policy } from '../../../../../../lib/policy/find-and-load-policy';
import { getInfo } from '../../../../../../lib/project-metadata/target-builders/git';
import { GitTarget } from '../../../../../../lib/ecosystems/types';
import { Contributor } from '../../../../../../lib/types';
import * as analytics from '../../../../../../lib/analytics';
import { getContributors } from '../../../../../../lib/monitor/dev-count-analysis';
import * as Debug from 'debug';
import {
AuthFailedError,
ValidationError,
} from '../../../../../../../lib/errors';
import { AuthFailedError, ValidationError } from '../../../../../../lib/errors';
import * as pathLib from 'path';

const debug = Debug('iac-cli-share-results');
import { ProjectAttributes, Tag } from '../../../../../../../lib/types';
import { TestLimitReachedError } from '../../usage-tracking';
import { getRepositoryRootForPath } from '../../../../../../../lib/iac/git';
import { ProjectAttributes, Tag } from '../../../../../../lib/types';
import { TestLimitReachedError } from '../usage-tracking';
import { getRepositoryRootForPath } from '../../../../../../lib/iac/git';

export async function shareResults({
results,
Expand Down
@@ -1,14 +1,14 @@
import { IaCErrorCodes } from '../../types';
import { CustomError } from '../../../../../../../lib/errors';
import { IaCErrorCodes } from '../types';
import { CustomError } from '../../../../../../lib/errors';
import {
CloudConfigFileTypes,
MapsDocIdToTree,
getLineNumber,
} from '@snyk/cloud-config-parser';
import { UnsupportedFileTypeError } from '../../file-parser';
import * as analytics from '../../../../../../../lib/analytics';
import { UnsupportedFileTypeError } from '../file-parser';
import * as analytics from '../../../../../../lib/analytics';
import * as Debug from 'debug';
import { getErrorStringCode } from '../../error-utils';
import { getErrorStringCode } from '../error-utils';
const debug = Debug('iac-extract-line-number');

export function getFileTypeForParser(fileType: string): CloudConfigFileTypes {
Expand Down
32 changes: 2 additions & 30 deletions src/cli/commands/test/iac/local-execution/process-results/index.ts
Expand Up @@ -6,8 +6,7 @@ import {
IacOrgSettings,
IaCTestFlags,
} from '../types';
import { processResults as processResultsV2 } from './v2';
import { processResults as processResultsV1 } from './v1';
import { processResults } from './process-results';

export interface ResultsProcessor {
processResults(
Expand Down Expand Up @@ -35,7 +34,7 @@ export class SingleGroupResultsProcessor implements ResultsProcessor {
tags: Tag[] | undefined,
attributes: ProjectAttributes | undefined,
): Promise<{ filteredIssues: FormattedResult[]; ignoreCount: number }> {
return processResultsV2(
return processResults(
resultsWithCustomSeverities,
this.orgPublicId,
this.iacOrgSettings,
Expand All @@ -47,30 +46,3 @@ export class SingleGroupResultsProcessor implements ResultsProcessor {
);
}
}

export class MultipleGroupsResultsProcessor implements ResultsProcessor {
constructor(
private pathToScan: string,
private orgPublicId: string,
private iacOrgSettings: IacOrgSettings,
private options: IaCTestFlags,
) {}

processResults(
resultsWithCustomSeverities: IacFileScanResult[],
policy: Policy | undefined,
tags: Tag[] | undefined,
attributes: ProjectAttributes | undefined,
): Promise<{ filteredIssues: FormattedResult[]; ignoreCount: number }> {
return processResultsV1(
resultsWithCustomSeverities,
this.orgPublicId,
this.iacOrgSettings,
policy,
tags,
attributes,
this.options,
this.pathToScan,
);
}
}
@@ -1,5 +1,5 @@
import { FormattedResult, PolicyMetadata } from '../../types';
import { Policy } from '../../../../../../../lib/policy/find-and-load-policy';
import { FormattedResult, PolicyMetadata } from '../types';
import { Policy } from '../../../../../../lib/policy/find-and-load-policy';

export function filterIgnoredIssues(
policy: Policy | undefined,
Expand Down
@@ -1,14 +1,14 @@
import { filterIgnoredIssues } from './policy';
import { formatAndShareResults } from './share-results';
import { formatScanResultsV2 } from '../../measurable-methods';
import { Policy } from '../../../../../../../lib/policy/find-and-load-policy';
import { ProjectAttributes, Tag } from '../../../../../../../lib/types';
import { formatScanResultsV2 } from '../measurable-methods';
import { Policy } from '../../../../../../lib/policy/find-and-load-policy';
import { ProjectAttributes, Tag } from '../../../../../../lib/types';
import {
FormattedResult,
IacFileScanResult,
IacOrgSettings,
IaCTestFlags,
} from '../../types';
} from '../types';

export async function processResults(
resultsWithCustomSeverities: IacFileScanResult[],
Expand Down
Expand Up @@ -6,22 +6,19 @@ import {
IaCTestFlags,
PolicyMetadata,
TestMeta,
} from '../../types';
import {
SEVERITY,
SEVERITIES,
} from '../../../../../../../lib/snyk-test/common';
import { IacProjectType } from '../../../../../../../lib/iac/constants';
import { CustomError } from '../../../../../../../lib/errors';
} from '../types';
import { SEVERITY, SEVERITIES } from '../../../../../../lib/snyk-test/common';
import { IacProjectType } from '../../../../../../lib/iac/constants';
import { CustomError } from '../../../../../../lib/errors';
import { extractLineNumber, getFileTypeForParser } from './extract-line-number';
import { getErrorStringCode } from '../../error-utils';
import { getErrorStringCode } from '../error-utils';
import {
MapsDocIdToTree,
getTrees,
parsePath,
} from '@snyk/cloud-config-parser';
import * as path from 'path';
import { isLocalFolder } from '../../../../../../../lib/detect';
import { isLocalFolder } from '../../../../../../lib/detect';

const severitiesArray = SEVERITIES.map((s) => s.verboseName);

Expand Down
@@ -1,4 +1,4 @@
import { IacFileScanResult, IacShareResultsFormat } from '../../types';
import { IacFileScanResult, IacShareResultsFormat } from '../types';
import * as path from 'path';

export function formatShareResults(
Expand Down
@@ -1,14 +1,10 @@
import { isFeatureFlagSupportedForOrg } from '../../../../../../../lib/feature-flags';
import { isFeatureFlagSupportedForOrg } from '../../../../../../lib/feature-flags';
import { shareResults } from './cli-share-results';
import { Policy } from '../../../../../../../lib/policy/find-and-load-policy';
import { ProjectAttributes, Tag } from '../../../../../../../lib/types';
import { FeatureFlagError } from '../../assert-iac-options-flag';
import { Policy } from '../../../../../../lib/policy/find-and-load-policy';
import { ProjectAttributes, Tag } from '../../../../../../lib/types';
import { FeatureFlagError } from '../assert-iac-options-flag';
import { formatShareResults } from './share-results-formatter';
import {
IacFileScanResult,
IaCTestFlags,
ShareResultsOutput,
} from '../../types';
import { IacFileScanResult, IaCTestFlags, ShareResultsOutput } from '../types';

export async function formatAndShareResults({
results,
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 2037cb2

Please sign in to comment.