This commit is contained in:
2026-04-07 14:50:23 +09:00
commit b4e485502b
4778 changed files with 2017091 additions and 0 deletions

View File

@@ -0,0 +1 @@
export default function about(): void;

View File

@@ -0,0 +1,10 @@
import { ICreateAppRequest } from '../../../lib/apps';
/**
* Function to process the app creation request and
* handle any errors that are request error and print
* in a formatted string. It throws is error is unknown
* or cannot be handled.
* @param {ICreateAppRequest} data to create the app
* @returns {String} response formatted string
*/
export declare function createApp(data: ICreateAppRequest): Promise<string | void>;

View File

@@ -0,0 +1,2 @@
import { MethodArgs } from '../../args';
export default function apps(...args0: MethodArgs): Promise<string | undefined | any>;

View File

@@ -0,0 +1 @@
export default function auth(apiToken: string): Promise<string>;

View File

@@ -0,0 +1 @@
export declare function verifyAPI(api: any): Promise<unknown>;

View File

@@ -0,0 +1 @@
export default function config(method?: 'set' | 'get' | 'unset' | 'clear', ...args: string[]): Promise<string>;

View File

@@ -0,0 +1,7 @@
import { MethodArgs } from '../args';
import { CustomError } from '../../lib/errors';
export declare class FlagError extends CustomError {
constructor(flag: string);
}
declare const _default: (...args: MethodArgs) => Promise<any>;
export default _default;

View File

@@ -0,0 +1,3 @@
import { TestResult } from '../../../lib/ecosystems/types';
import { TestResult as LegacyTestResult } from '../../../lib/snyk-test/legacy';
export declare function convertLegacyTestResultToNew(testResult: LegacyTestResult): TestResult;

View File

@@ -0,0 +1,3 @@
import { ScanResult } from '../../../lib/ecosystems/types';
import { TestResult } from '../../../lib/snyk-test/legacy';
export declare function convertLegacyTestResultToScanResult(testResult: TestResult): ScanResult;

View File

@@ -0,0 +1,4 @@
import { TestResult } from '../../../lib/snyk-test/legacy';
import { EntityToFix } from '@snyk/fix';
import { Options, TestOptions } from '../../../lib/types';
export declare function convertLegacyTestResultToFixEntities(testResults: (TestResult | TestResult[]) | Error, root: string, options: Partial<Options & TestOptions>): EntityToFix[];

View File

@@ -0,0 +1 @@
export declare function getDisplayPath(path: string): string;

View File

@@ -0,0 +1,2 @@
import { MethodArgs } from '../../args';
export default function fix(...args: MethodArgs): Promise<string>;

View File

@@ -0,0 +1,2 @@
import { Options, TestOptions } from '../../../lib/types';
export declare function validateFixCommandIsSupported(options: Options & TestOptions): Promise<boolean>;

View File

@@ -0,0 +1,3 @@
import { MethodArgs } from '../../args';
export declare function findHelpFile(helpArgs: string[], helpFolderPath?: string): string;
export default function help(...args: MethodArgs): Promise<string>;

View File

@@ -0,0 +1 @@
export declare function renderMarkdown(markdown: string): string;

View File

@@ -0,0 +1,28 @@
/**
Code in this file is adapted from mikaelbr/marked-terminal
https://github.com/mikaelbr/marked-terminal/blob/7501b8bb24a5ed52ec7d9114d4aeefa14f1bf5e6/index.js#L234-L330
MIT License
Copyright (c) 2017 Mikael Brevik
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
export declare function reflowText(text: string, width: number): string;

View File

@@ -0,0 +1,4 @@
import { MethodResult } from './types';
export default function ignore(options: any): Promise<MethodResult>;
export declare function ignoreIssue(options: any): Promise<MethodResult>;
export declare function excludeFilePathPattern(options: any): Promise<MethodResult>;

View File

@@ -0,0 +1,20 @@
export = commands;
declare const commands: {
auth: (...args: any[]) => Promise<any>;
config: (...args: any[]) => Promise<any>;
'update-exclude-policy': (...args: any[]) => Promise<any>;
describe: (...args: any[]) => Promise<any>;
help: (...args: any[]) => Promise<any>;
ignore: (...args: any[]) => Promise<any>;
monitor: (...args: any[]) => Promise<any>;
fix: (...args: any[]) => Promise<any>;
policy: (...args: any[]) => Promise<any>;
protect: (...args: any[]) => Promise<any>;
test: (...args: any[]) => Promise<any>;
version: (...args: any[]) => Promise<any>;
about: (...args: any[]) => Promise<any>;
wizard: (...args: any[]) => Promise<any>;
woof: (...args: any[]) => Promise<any>;
log4shell: (...args: any[]) => Promise<any>;
apps: (...args: any[]) => Promise<any>;
};

View File

@@ -0,0 +1,12 @@
/**
* The content of this file is generated by a tool.
* Don't edit it manually!
* */
export type FileSignatureDetails = {
versions: string[];
filename: string;
};
export type VulnerableSignatures = {
[signature: string]: FileSignatureDetails;
};
export declare const vulnerableSignatures: VulnerableSignatures;

View File

@@ -0,0 +1,2 @@
import { MethodArgs } from '../args';
export default function log4shell(...args: MethodArgs): Promise<void>;

View File

@@ -0,0 +1,17 @@
import { ProjectAttributes, Tag } from '../../../lib/types';
import { MethodArgs } from '../../args';
export default function monitor(...args0: MethodArgs): Promise<any>;
export declare function validateProjectAttributes(options: any): void;
export declare function generateProjectAttributes(options: any): ProjectAttributes;
/**
* Parse CLI --tags options into an internal data structure.
*
* If this returns undefined, it means "do not touch the existing tags on the project".
*
* Anything else means "replace existing tags on the project with this list" even if empty.
*
* @param options CLI options
* @returns List of parsed tags or undefined if they are to be left untouched.
*/
export declare function generateTags(options: any): Tag[] | undefined;
export declare function validateTags(options: any): void;

View File

@@ -0,0 +1,2 @@
import { GoodResult, BadResult } from './types';
export declare function processJsonMonitorResponse(results: Array<GoodResult | BadResult>): string;

View File

@@ -0,0 +1,12 @@
import { MonitorError } from '../../../lib/errors';
export interface GoodResult {
ok: true;
data: string;
path: string;
projectName?: string;
}
export interface BadResult {
ok: false;
data: MonitorError;
path: string;
}

View File

@@ -0,0 +1 @@
export default function displayPolicy(path?: string): Promise<string>;

View File

@@ -0,0 +1,5 @@
import { Options } from '../../lib/types';
export declare function processCommandArgs<CommandOptions>(...args: any[]): {
paths: string[];
options: Options & CommandOptions;
};

View File

@@ -0,0 +1 @@
export default function protectFunc(): void;

View File

@@ -0,0 +1 @@
export default function wizard(): void;

View File

@@ -0,0 +1 @@
export declare function formatTestError(error: any): any;

View File

@@ -0,0 +1,5 @@
import { MethodArgs } from '../../../args';
import { TestCommandResult } from '../../types';
import { IaCTestFlags } from './local-execution/types';
export default function (...args: MethodArgs): Promise<TestCommandResult>;
export declare function getFlag(options: IaCTestFlags, flag: string): string | undefined;

View File

@@ -0,0 +1,8 @@
import { FormattedResult, PerformanceAnalyticsKey, RulesOrigin } from './types';
import { DescribeOptions, DriftAnalysis } from '../../../../../lib/iac/types';
export declare function addIacAnalytics(formattedResults: FormattedResult[], opts: {
ignoredIssuesCount: number;
rulesOrigin: RulesOrigin;
}): void;
export declare const performanceAnalyticsObject: Record<PerformanceAnalyticsKey, number | null>;
export declare function addIacDriftAnalytics(analysis: DriftAnalysis, options: DescribeOptions): void;

View File

@@ -0,0 +1,45 @@
import { CustomError } from '../../../../../lib/errors';
import { IacOrgSettings } from './types';
import { Options, TestOptions } from '../../../../../lib/types';
export declare class FlagError extends CustomError {
constructor(key: string);
}
export declare class IntegratedFlagError extends CustomError {
constructor(key: string, org: string);
}
export declare class FeatureFlagError extends CustomError {
constructor(key: string, featureFlag: string, hasSnykPreview?: boolean);
}
export declare class FlagValueError extends CustomError {
constructor(key: string, value: string, supportedValues: string);
}
export declare class UnsupportedEntitlementFlagError extends CustomError {
constructor(key: string, entitlementName: string);
}
export declare class UnsupportedEntitlementCommandError extends CustomError {
constructor(key: string, entitlementName: string);
}
/**
* Validates the command line flags passed to the snyk iac test
* command. The current argument parsing is very permissive and
* allows unknown flags to be provided without validation.
*
* For snyk iac we need to explicitly validate the flags to avoid
* misconfigurations and typos. For example, if the --experimental
* flag were to be misspelled we would end up sending the client
* data to our backend rather than running it locally as intended.
* @param argv command line args passed to the process
*/
export declare function assertIaCOptionsFlags(argv: string[]): void;
/**
* Check that the flags used for the v1 flow do not contain any flag that are
* only usable with the new IaC+ flow
* @param settings organisation settings, used to get the org name
* @param argv command line args
*/
export declare function assertIntegratedIaCOnlyOptions(settings: IacOrgSettings, argv: string[]): void;
export declare function assertTerraformPlanModes(scanModeArgValue: string): void;
export declare function isIacShareResultsOptions(options: Options & TestOptions): boolean | undefined;
export declare class InvalidArgumentError extends CustomError {
constructor(key: string);
}

View File

@@ -0,0 +1,22 @@
/**
* Gets all nested directories for the path that we ran a scan.
* @param pathToScan - the path to scan provided by the user
* @param maxDepth? - An optional `maxDepth` argument can be provided to limit how deep in the file tree the search will go.
* @returns {string[]} An array with all the non-empty nested directories in this path
*/
export declare function getAllDirectoriesForPath(pathToScan: string, maxDepth?: number): string[];
/**
* Gets all file paths for the specific directory
* @param pathToScan - the path to scan provided by the user
* @param currentDirectory - the directory which we want to return files for
* @returns {string[]} An array with all the Terraform filePaths for this directory
*/
export declare function getFilesForDirectory(pathToScan: string, currentDirectory: string): string[];
/**
* Iterates through the makeFileAndDirectoryGenerator function and gets all the Terraform files in the specified directory
* @param pathToScan - the pathToScan to scan provided by the user
* @returns {Generator<string>} - a generator which holds all the filepaths
*/
export declare function getFilesForDirectoryGenerator(pathToScan: string): Generator<string>;
export declare const shouldBeParsed: (pathToScan: string) => boolean;
export declare const getFileType: (pathToScan: string) => string;

View File

@@ -0,0 +1 @@
export declare function getErrorStringCode(code: number): string;

View File

@@ -0,0 +1,11 @@
import { IacFileData } from './types';
import { CustomError } from '../../../../../lib/errors';
export declare function loadContentForFiles(filePaths: string[]): Promise<IacFileData[]>;
export declare function tryLoadFileData(pathToScan: string): Promise<IacFileData>;
export declare class NoFilesToScanError extends CustomError {
constructor(message?: string);
}
export declare class FailedToLoadFileError extends CustomError {
filename: string;
constructor(filename: string);
}

View File

@@ -0,0 +1,9 @@
import { IacFileData, IacFileParsed, IaCTestFlags, ParsingResults } from './types';
import { CustomError } from '../../../../../lib/errors';
export declare function parseFiles(filesData: IacFileData[], options?: IaCTestFlags): Promise<ParsingResults>;
export declare function parseNonTerraformFiles(filesData: IacFileData[], options: IaCTestFlags): ParsingResults;
export declare function parseTerraformFiles(filesData: IacFileData[]): ParsingResults;
export declare function tryParseIacFile(fileData: IacFileData, options?: IaCTestFlags): IacFileParsed[];
export declare class UnsupportedFileTypeError extends CustomError {
constructor(fileType: string);
}

View File

@@ -0,0 +1,18 @@
import { IacFileParsed, IacFileScanResult } from './types';
import { CustomError } from '../../../../../lib/errors';
import { IacFileInDirectory } from '../../../../../lib/types';
export declare function scanFiles(parsedFiles: Array<IacFileParsed>): Promise<{
scannedFiles: IacFileScanResult[];
failedScans: IacFileInDirectory[];
}>;
export declare function validateResultFromCustomRules(result: IacFileScanResult): {
validatedResult: IacFileScanResult;
invalidIssues: IacFileInDirectory[];
};
export declare function clearPolicyEngineCache(): void;
export declare class FailedToBuildPolicyEngine extends CustomError {
constructor(message?: string);
}
export declare class FailedToExecutePolicyEngine extends CustomError {
constructor(message?: string);
}

View File

@@ -0,0 +1,12 @@
/// <reference types="node" />
export declare function createIacDir(): void;
export declare function extractBundle(response: NodeJS.ReadableStream): Promise<void>;
export declare function isValidBundle(wasmPath: string, dataPath: string): boolean;
export declare function computeCustomRulesBundleChecksum(): string | undefined;
/**
* makeFileAndDirectoryGenerator is a generator function that helps walking the directory and file structure of this pathToScan
* @param root
* @param maxDepth? - An optional `maxDepth` argument can be provided to limit how deep in the file tree the search will go.
* @returns {Generator<object>} - a generator which yields an object with directories or paths for the path to scan
*/
export declare function makeFileAndDirectoryGenerator(root?: string, maxDepth?: number): Generator<any, void, any>;

View File

@@ -0,0 +1,10 @@
import { IacFileParsed, IacFileParseFailure, IacOrgSettings, IaCTestFlags, RulesOrigin, SafeAnalyticsOutput, TestReturnValue } from './types';
import { ResultsProcessor } from './process-results';
import { CustomError } from '../../../../../lib/errors';
import { Tag } from '../../../../../lib/types';
export declare function test(resultsProcessor: ResultsProcessor, pathToScan: string, options: IaCTestFlags, iacOrgSettings: IacOrgSettings, rulesOrigin: RulesOrigin): Promise<TestReturnValue>;
export declare function removeFileContent({ filePath, fileType, failureReason, projectType, }: IacFileParsed | IacFileParseFailure): SafeAnalyticsOutput;
export declare function parseTags(options: IaCTestFlags): Tag[] | undefined;
export declare class InvalidVarFilePath extends CustomError {
constructor(path: string, message?: string);
}

View File

@@ -0,0 +1,25 @@
import { EngineType } from './types';
import { CustomError } from '../../../../../lib/errors';
export declare const LOCAL_POLICY_ENGINE_DIR: string;
export declare const CUSTOM_POLICY_ENGINE_WASM_PATH: string;
export declare function assertNever(value: never): never;
export declare function getLocalCachePath(engineType: EngineType): string[];
export declare function initLocalCache({ customRulesPath, }?: {
customRulesPath?: string;
}): Promise<void>;
export declare function cleanLocalCache(): void;
export declare class FailedToInitLocalCacheError extends CustomError {
constructor(message?: string);
}
export declare class FailedToDownloadRulesError extends CustomError {
constructor(message?: string);
}
export declare class FailedToExtractCustomRulesError extends CustomError {
constructor(path: string, message?: string);
}
export declare class InvalidCustomRules extends CustomError {
constructor(path: string, message?: string);
}
export declare class InvalidCustomRulesPath extends CustomError {
constructor(path: string, message?: string);
}

View File

@@ -0,0 +1,21 @@
import { PerformanceAnalyticsKey } from './types';
type Awaited<T> = T extends PromiseLike<infer U> ? U : T;
export declare function asyncPerformanceAnalyticsDecorator<T extends (...args: any[]) => Promise<any>>(measurableMethod: T, analyticsKey: PerformanceAnalyticsKey): (...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>>;
export declare function performanceAnalyticsDecorator<T extends (...args: any[]) => any>(measurableMethod: T, analyticsKey: PerformanceAnalyticsKey): (...args: Parameters<T>) => ReturnType<T>;
declare const measurableInitLocalCache: (args_0?: {
customRulesPath?: string | undefined;
} | undefined) => Promise<void>;
declare const measurableParseFiles: (filesData: import("./types").IacFileData[], options?: import("./types").IaCTestFlags | undefined) => Promise<import("./types").ParsingResults>;
declare const measurableloadContentForFiles: (filePaths: string[]) => Promise<import("./types").IacFileData[]>;
declare const measurableScanFiles: (parsedFiles: import("./types").IacFileParsed[]) => Promise<{
scannedFiles: import("./types").IacFileScanResult[];
failedScans: import("../../../../../lib/types").IacFileInDirectory[];
}>;
declare const measurableGetIacOrgSettings: (publicOrgId?: string | undefined) => Promise<import("./types").IacOrgSettings>;
declare const measurableApplyCustomSeverities: (scannedFiles: import("./types").IacFileScanResult[], customPolicies: import("./types").IacCustomPolicies) => Promise<import("./types").IacFileScanResult[]>;
declare const measurableCleanLocalCache: () => void;
declare const measurableFormatScanResults: (scanResults: import("./types").IacFileScanResult[], options: import("./types").IaCTestFlags, meta: import("./types").TestMeta, projectPublicIds: Record<string, string>, projectRoot: string, gitRemoteUrl?: string | undefined) => import("./types").FormattedResult[];
declare const measurableTrackUsage: (formattedResults: import("./usage-tracking").TrackableResult[], org: string) => Promise<void>;
declare const measurableLocalTest: (resultsProcessor: import("./process-results").ResultsProcessor, pathToScan: string, options: import("./types").IaCTestFlags, iacOrgSettings: import("./types").IacOrgSettings, rulesOrigin: import("./types").RulesOrigin) => Promise<import("./types").TestReturnValue>;
declare const measurableOciPull: (registry: import("./rules/oci-registry").OciRegistry, repository: string, tag: string) => Promise<string>;
export { measurableInitLocalCache as initLocalCache, measurableloadContentForFiles as loadContentForFiles, measurableParseFiles as parseFiles, measurableScanFiles as scanFiles, measurableGetIacOrgSettings as getIacOrgSettings, measurableApplyCustomSeverities as applyCustomSeverities, measurableFormatScanResults as formatScanResults, measurableTrackUsage as trackUsage, measurableCleanLocalCache as cleanLocalCache, measurableLocalTest as localTest, measurableOciPull as pull, };

View File

@@ -0,0 +1,2 @@
import { IacCustomPolicies, IacFileScanResult } from '../types';
export declare function applyCustomSeverities(scannedFiles: IacFileScanResult[], customPolicies: IacCustomPolicies): Promise<IacFileScanResult[]>;

View File

@@ -0,0 +1,6 @@
import { IacOrgSettings } from '../types';
import { CustomError } from '../../../../../../lib/errors';
export declare function getIacOrgSettings(publicOrgId?: string): Promise<IacOrgSettings>;
export declare class FailedToGetIacOrgSettingsError extends CustomError {
constructor(message?: string);
}

View File

@@ -0,0 +1,6 @@
import { IacFileData, IacFileParsed } from '../types';
export declare const REQUIRED_K8S_FIELDS: string[];
export declare const REQUIRED_CLOUDFORMATION_FIELDS: string[];
export declare const REQUIRED_ARM_FIELDS: string[];
export declare function detectConfigType(fileData: IacFileData, parsedIacFiles: any[]): IacFileParsed[];
export declare function checkRequiredFieldsMatch(parsedDocument: any, requiredFields: string[]): boolean;

View File

@@ -0,0 +1,10 @@
type FilePath = string;
type FileContent = string;
type MapOfFiles = Record<FilePath, FileContent>;
type ParsedResults = {
parsedFiles: MapOfFiles;
failedFiles: MapOfFiles;
debugLogs: MapOfFiles;
};
export default function hclToJsonV2(files: MapOfFiles): ParsedResults;
export {};

View File

@@ -0,0 +1,5 @@
import { CustomError } from '../../../../../../lib/errors';
export declare class FailedToParseTerraformFileError extends CustomError {
filename: string;
constructor(filename: string);
}

View File

@@ -0,0 +1,9 @@
import { IacFileData, IacFileParsed, TerraformPlanJson } from '../types';
import { CustomError } from '../../../../../../lib/errors';
export declare function isTerraformPlan(terraformPlanJson: TerraformPlanJson): boolean;
export declare function tryParsingTerraformPlan(terraformPlanFile: IacFileData, terraformPlanJson: TerraformPlanJson, { isFullScan }?: {
isFullScan: boolean;
}): Array<IacFileParsed>;
export declare class FailedToExtractResourcesInTerraformPlanError extends CustomError {
constructor(message?: string);
}

View File

@@ -0,0 +1,11 @@
import { IacShareResultsFormat, IaCTestFlags, ShareResultsOutput } from '../types';
import { Policy } from 'snyk-policy';
import { IacOutputMeta, ProjectAttributes, Tag } from '../../../../../../lib/types';
export declare function shareResults({ results, policy, tags, attributes, options, meta, }: {
results: IacShareResultsFormat[];
policy: Policy | undefined;
tags?: Tag[];
attributes?: ProjectAttributes;
options: IaCTestFlags;
meta: IacOutputMeta;
}): Promise<ShareResultsOutput>;

View File

@@ -0,0 +1,3 @@
import { CloudConfigFileTypes, MapsDocIdToTree } from '@snyk/cloud-config-parser';
export declare function getFileTypeForParser(fileType: string): CloudConfigFileTypes;
export declare function extractLineNumber(cloudConfigPath: string[], fileType: CloudConfigFileTypes, treeByDocId: MapsDocIdToTree): number;

View File

@@ -0,0 +1,21 @@
import { Policy } from 'snyk-policy';
import { IacOutputMeta, ProjectAttributes, Tag } from '../../../../../../lib/types';
import { FormattedResult, IacFileScanResult, IacOrgSettings, IaCTestFlags } from '../types';
export interface ResultsProcessor {
processResults(resultsWithCustomSeverities: IacFileScanResult[], policy: Policy | undefined, tags: Tag[] | undefined, attributes: ProjectAttributes | undefined): Promise<{
filteredIssues: FormattedResult[];
ignoreCount: number;
}>;
}
export declare class SingleGroupResultsProcessor implements ResultsProcessor {
private projectRoot;
private orgPublicId;
private iacOrgSettings;
private options;
private meta;
constructor(projectRoot: string, orgPublicId: string, iacOrgSettings: IacOrgSettings, options: IaCTestFlags, meta: IacOutputMeta);
processResults(resultsWithCustomSeverities: IacFileScanResult[], policy: Policy | undefined, tags: Tag[] | undefined, attributes: ProjectAttributes | undefined): Promise<{
filteredIssues: FormattedResult[];
ignoreCount: number;
}>;
}

View File

@@ -0,0 +1,6 @@
import { FormattedResult } from '../types';
import { Policy } from 'snyk-policy';
export declare function filterIgnoredIssues(policy: Policy | undefined, results: FormattedResult[]): {
filteredIssues: FormattedResult[];
ignoreCount: number;
};

View File

@@ -0,0 +1,7 @@
import { Policy } from 'snyk-policy';
import { IacOutputMeta, ProjectAttributes, Tag } from '../../../../../../lib/types';
import { FormattedResult, IacFileScanResult, IacOrgSettings, IaCTestFlags } from '../types';
export declare function processResults(resultsWithCustomSeverities: IacFileScanResult[], orgPublicId: string, iacOrgSettings: IacOrgSettings, policy: Policy | undefined, tags: Tag[] | undefined, attributes: ProjectAttributes | undefined, options: IaCTestFlags, projectRoot: string, meta: IacOutputMeta): Promise<{
filteredIssues: FormattedResult[];
ignoreCount: number;
}>;

View File

@@ -0,0 +1,8 @@
import { FormattedResult, IacFileScanResult, IaCTestFlags, PolicyMetadata, TestMeta } from '../types';
import { SEVERITY } from '../../../../../../lib/snyk-test/common';
import { CustomError } from '../../../../../../lib/errors';
export declare function formatScanResults(scanResults: IacFileScanResult[], options: IaCTestFlags, meta: TestMeta, projectPublicIds: Record<string, string>, projectRoot: string, gitRemoteUrl?: string): FormattedResult[];
export declare function filterPoliciesBySeverity(violatedPolicies: PolicyMetadata[], severityThreshold?: SEVERITY): PolicyMetadata[];
export declare class FailedToFormatResults extends CustomError {
constructor(message?: string);
}

View File

@@ -0,0 +1,3 @@
import { IacFileScanResult, IacShareResultsFormat } from '../types';
import { IacOutputMeta } from '../../../../../../lib/types';
export declare function formatShareResults(projectRoot: string, scanResults: IacFileScanResult[], meta: IacOutputMeta): IacShareResultsFormat[];

View File

@@ -0,0 +1,13 @@
import { Policy } from 'snyk-policy';
import { IacOutputMeta, ProjectAttributes, Tag } from '../../../../../../lib/types';
import { IacFileScanResult, IaCTestFlags, ShareResultsOutput } from '../types';
export declare function formatAndShareResults({ results, options, orgPublicId, policy, tags, attributes, projectRoot, meta, }: {
results: IacFileScanResult[];
options: IaCTestFlags;
orgPublicId: string;
policy: Policy | undefined;
tags?: Tag[];
attributes?: ProjectAttributes;
projectRoot: string;
meta: IacOutputMeta;
}): Promise<ShareResultsOutput>;

View File

@@ -0,0 +1,29 @@
import { OCIRegistryURLComponents } from '../types';
import { CustomError } from '../../../../../../lib/errors';
import { OciRegistry } from './oci-registry';
export declare const CUSTOM_RULES_TARBALL = "custom-bundle.tar.gz";
export declare function extractOCIRegistryURLComponents(OCIRegistryURL: string): OCIRegistryURLComponents;
/**
* Downloads an OCI Artifact from a remote OCI Registry and writes it to the
* disk. The artifact here is a custom rules bundle stored in a remote registry.
* In order to do that, it calls an external docker registry v2 client to get
* the manifests, the layers and then builds the artifact. Example:
* https://github.com/opencontainers/image-spec/blob/main/manifest.md#example-image-manifest
*
* @param registry The client for accessing an OCI registry.
* @param repository The name of an OCI repository.
* @param tag The tag of an image in an OCI repository.
**/
export declare function pull(registry: OciRegistry, repository: string, tag: string): Promise<string>;
export declare class FailedToBuildOCIArtifactError extends CustomError {
constructor(message?: string);
}
export declare class InvalidManifestSchemaVersionError extends CustomError {
constructor(message?: string);
}
export declare class InvalidRemoteRegistryURLError extends CustomError {
constructor(url?: string);
}
export declare class UnsupportedEntitlementPullError extends CustomError {
constructor(entitlement: string);
}

View File

@@ -0,0 +1,24 @@
/// <reference types="node" />
export type GetManifestResponse = {
schemaVersion: number;
layers: Layer[];
};
export type Layer = {
digest: string;
};
export type GetLayerResponse = {
blob: Buffer;
};
export interface OciRegistry {
getManifest(repository: string, tag: string): Promise<GetManifestResponse>;
getLayer(repository: string, digest: string): Promise<GetLayerResponse>;
}
export declare class RemoteOciRegistry implements OciRegistry {
private registry;
private username?;
private password?;
private static options;
constructor(registry: string, username?: string | undefined, password?: string | undefined);
getManifest(repository: string, tag: string): Promise<GetManifestResponse>;
getLayer(repository: string, digest: string): Promise<GetLayerResponse>;
}

View File

@@ -0,0 +1,15 @@
import { IacOrgSettings, IaCTestFlags, RulesOrigin } from '../types';
import { CustomError } from '../../../../../../lib/errors';
import { OciRegistry } from './oci-registry';
export declare function initRules(buildOciRegistry: () => OciRegistry, iacOrgSettings: IacOrgSettings, options: IaCTestFlags, orgPublicId: string): Promise<RulesOrigin>;
export declare function buildDefaultOciRegistry(settings: IacOrgSettings): OciRegistry;
/**
* Pull and store the IaC custom-rules bundle from the remote OCI Registry.
*/
export declare function pullIaCCustomRules(buildOciRegistry: () => OciRegistry, iacOrgSettings: IacOrgSettings): Promise<string>;
export declare class FailedToPullCustomBundleError extends CustomError {
constructor(message?: string);
}
export declare class FailedToExecuteCustomRulesError extends CustomError {
constructor(message?: string);
}

View File

@@ -0,0 +1,292 @@
import { IacFileTypes, IacProjectType, IacProjectTypes } from '../../../../../lib/iac/constants';
import { SEVERITY } from '../../../../../lib/snyk-test/common';
import { AnnotatedIssue, IgnoreSettings, TestResult } from '../../../../../lib/snyk-test/legacy';
import { IacFileInDirectory, Options, TestOptions, PolicyOptions } from '../../../../../lib/types';
export interface IacFileData extends IacFileInDirectory {
fileContent: string;
}
export declare const VALID_FILE_TYPES: string[];
export declare const VALID_TERRAFORM_FILE_TYPES: string[];
export interface IacFileParsed extends IacFileData {
jsonContent: Record<string, unknown> | TerraformScanInput;
projectType: IacProjectType;
engineType: EngineType;
docId?: number;
}
export interface IacFileParseFailure extends IacFileData {
jsonContent: null;
engineType: null;
failureReason: string;
err: Error;
}
export type ParsingResults = {
parsedFiles: Array<IacFileParsed>;
failedFiles: Array<IacFileParseFailure>;
};
export interface IacFileScanResult extends IacFileParsed {
violatedPolicies: PolicyMetadata[];
}
export interface IacShareResultsFormat {
projectName: string;
targetFile: string;
filePath: string;
fileType: IacFileTypes;
projectType: IacProjectType;
violatedPolicies: PolicyMetadata[];
}
export interface FormattedTestMeta {
isPrivate: boolean;
isLicensesEnabled: boolean;
org: string;
orgPublicId: string;
ignoreSettings?: IgnoreSettings | null;
projectId?: string;
policy?: string;
gitRemoteUrl?: string;
}
export type FormattedResult = {
result: {
cloudConfigResults: Array<PolicyMetadata>;
projectType: IacProjectTypes;
};
meta: FormattedTestMeta;
filesystemPolicy: boolean;
vulnerabilities: AnnotatedIssue[];
dependencyCount: number;
licensesPolicy: object | null;
ignoreSettings: IgnoreSettings | null;
targetFile: string;
projectName: string;
org: string;
policy: string;
isPrivate: boolean;
targetFilePath: string;
packageManager: IacProjectType;
};
export type IacCustomPolicies = Record<string, {
severity?: string;
}>;
export declare enum RulesOrigin {
Local = "local",
Remote = "remote",
Internal = "internal"
}
export interface IacCustomRules {
isEnabled?: boolean;
ociRegistryURL?: string;
ociRegistryTag?: string;
}
export interface IacEntitlements {
infrastructureAsCode?: boolean;
iacDrift?: boolean;
iacCustomRulesEntitlement?: boolean;
}
export interface IacOrgSettings {
meta: TestMeta;
customPolicies: IacCustomPolicies;
customRules?: IacCustomRules;
entitlements?: IacEntitlements;
}
export interface TestMeta {
org: string;
orgPublicId: string;
ignoreSettings?: IgnoreSettings | null;
projectId?: string;
gitRemoteUrl?: string;
}
export interface OpaWasmInstance {
evaluate: (data: Record<string, any>) => {
results: PolicyMetadata[];
};
setData: (data: Record<string, any>) => void;
}
export type SafeAnalyticsOutput = Omit<IacFileParsed | IacFileParseFailure, 'fileContent' | 'jsonContent' | 'engineType'>;
export declare enum EngineType {
Kubernetes = 0,
Terraform = 1,
CloudFormation = 2,
ARM = 3,
Custom = 4
}
export interface PolicyMetadata {
id?: string;
publicId: string;
type?: string;
subType: string;
title: string;
documentation?: string;
isGeneratedByCustomRule?: boolean;
description?: string;
severity: SEVERITY | 'none';
msg: string;
issue: string;
impact: string;
resolve: string;
references: string[];
remediation?: Partial<Record<'terraform' | 'cloudformation' | 'arm' | 'kubernetes', string>>;
docId?: number;
}
export type IaCTestFlags = Pick<Options & TestOptions & PolicyOptions, 'org' | 'insecure' | 'debug' | 'experimental' | 'detectionDepth' | 'severityThreshold' | 'json' | 'sarif' | 'report' | 'target-reference' | 'var-file' | 'ignore-policy' | 'policy-path' | 'tags' | 'remote-repo-url' | 'target-name'> & {
'json-file-output'?: string;
'sarif-file-output'?: string;
v?: boolean;
version?: boolean;
h?: boolean;
help?: 'help';
q?: boolean;
quiet?: boolean;
path?: string;
rules?: string;
'custom-rules'?: boolean;
'snyk-cloud-environment'?: string;
'project-tags'?: string;
'project-environment'?: string;
'project-lifecycle'?: string;
'project-business-criticality'?: string;
'iac-test-output-file'?: string;
} & TerraformPlanFlags;
interface TerraformPlanFlags {
scan?: TerraformPlanScanMode;
}
export declare enum TerraformPlanScanMode {
DeltaScan = "resource-changes",
FullScan = "planned-values"
}
export interface TerraformPlanResource {
address: string;
mode: string;
type: string;
name: string;
values: Record<string, unknown>;
index: number | string;
}
export interface TerraformPlanResourceChange extends Omit<TerraformPlanResource, 'values'> {
change: {
actions: ResourceActions;
before: Record<string, unknown> | null;
after: Record<string, unknown> | null;
};
}
export interface TerraformPlanJson {
resource_changes: Array<TerraformPlanResourceChange>;
configuration: {
root_module: {
resources: Array<TerraformPlanReferencedResource>;
};
};
}
export interface TerraformPlanReferencedResource extends TerraformPlanResource {
expressions?: Record<string, TerraformPlanExpression>;
}
export interface TerraformPlanExpression {
references: Array<string>;
}
export interface TerraformScanInput {
resource: Record<string, Record<string, unknown>>;
data: Record<string, Record<string, unknown>>;
}
export type ResourceActions = ['no-op'] | ['create'] | ['read'] | ['update'] | ['delete', 'create'] | ['create', 'delete'] | ['delete'];
export declare const VALID_RESOURCE_ACTIONS_FOR_DELTA_SCAN: ResourceActions[];
export declare const VALID_RESOURCE_ACTIONS_FOR_FULL_SCAN: ResourceActions[];
export declare enum IaCErrorCodes {
FailedToInitLocalCacheError = 1000,
FailedToCleanLocalCacheError = 1001,
FailedToDownloadRulesError = 1002,
FailedToExtractCustomRulesError = 1003,
InvalidCustomRules = 1004,
InvalidCustomRulesPath = 1005,
InvalidVarFilePath = 1006,
NoFilesToScanError = 1010,
FailedToLoadFileError = 1011,
CurrentWorkingDirectoryTraversalError = 1012,
UnsupportedFileTypeError = 1020,
InvalidJsonFileError = 1021,
InvalidYamlFileError = 1022,
FailedToDetectJsonConfigError = 1023,
FailedToDetectYamlConfigError = 1024,
MissingRequiredFieldsInKubernetesYamlError = 1031,
FailedToParseHelmError = 1032,
FailedToParseTerraformFileError = 1040,
FailedToExtractResourcesInTerraformPlanError = 1052,
FailedToBuildPolicyEngine = 1060,
FailedToExecutePolicyEngine = 1061,
FailedToFormatResults = 1070,
FailedToExtractLineNumberError = 1071,
FailedToGetIacOrgSettingsError = 1080,
FlagError = 1090,
FlagValueError = 1091,
UnsupportedEntitlementFlagError = 1092,
FeatureFlagError = 1093,
InvalidArgumentError = 1094,
FailedToExecuteCustomRulesError = 1100,
FailedToPullCustomBundleError = 1101,
FailedToBuildOCIArtifactError = 1102,
InvalidRemoteRegistryURLError = 1103,
InvalidManifestSchemaVersionError = 1104,
UnsupportedFeatureFlagPullError = 1105,
UnsupportedEntitlementPullError = 1106,
InvalidServiceError = 1110,
InvalidUserRulesBundlePathError = 1130,
InvalidUserPolicyEnginePathError = 1140,
FailedToDownloadPolicyEngineError = 1141,
FailedToCachePolicyEngineError = 1142,
PolicyEngineScanError = 1150,
NoPaths = 2000,
CwdTraversal = 2003,
NoBundle = 2004,
OpenBundle = 2005,
InvalidSeverityThreshold = 2006,
Scan = 2100,
UnableToRecognizeInputType = 2101,
UnsupportedInputType = 2102,
UnableToResolveLocation = 2103,
UnrecognizedFileExtension = 2104,
FailedToParseInput = 2105,
InvalidInput = 2106,
UnableToReadFile = 2107,
UnableToReadDir = 2108,
UnableToReadStdin = 2109,
FailedToLoadRegoAPI = 2110,
FailedToLoadRules = 2111,
FailedToCompile = 2112,
UnableToReadPath = 2113,
NoLoadableInput = 2114,
FailedToMakeResourcesResolvers = 2115,
ResourcesResolverError = 2116,
FailedToProcessResults = 2200,
EntitlementNotEnabled = 2201,
ReadSettings = 2202,
SubmoduleLoadingError = 3000,
MissingRemoteSubmodulesError = 3001,
EvaluationError = 3002,
MissingTermError = 3003
}
export interface TestReturnValue {
results: TestResult | TestResult[];
failures?: IacFileInDirectory[];
ignoreCount: number;
}
export interface OCIRegistryURLComponents {
registryBase: string;
repo: string;
tag: string;
}
export declare enum PerformanceAnalyticsKey {
InitLocalCache = "cache-init-ms",
FileLoading = "file-loading-ms",
FileParsing = "file-parsing-ms",
FileScanning = "file-scanning-ms",
OrgSettings = "org-settings-ms",
CustomSeverities = "custom-severities-ms",
ResultFormatting = "results-formatting-ms",
UsageTracking = "usage-tracking-ms",
CacheCleanup = "cache-cleanup-ms",
Total = "total-iac-ms"
}
export interface ShareResultsOutput {
projectPublicIds: {
[targetFile: string]: string;
};
gitRemoteUrl?: string;
}
export {};

View File

@@ -0,0 +1,4 @@
/**
* Checks if the provided URL string is valid.
*/
export declare function isValidUrl(urlStr: string): boolean;

View File

@@ -0,0 +1,13 @@
import { CustomError } from '../../../../../lib/errors';
export declare function trackUsage(formattedResults: TrackableResult[], org: string): Promise<void>;
export declare class TestLimitReachedError extends CustomError {
constructor();
}
export interface TrackableResult {
meta: {
isPrivate: boolean;
};
result: {
cloudConfigResults: any[];
};
}

View File

@@ -0,0 +1,11 @@
import { CustomError } from '../../../../../lib/errors';
import { IacFileData } from './types';
export declare function parseYAMLOrJSONFileData(fileData: IacFileData): any[];
export declare class InvalidJsonFileError extends CustomError {
filename: string;
constructor(filename: string);
}
export declare class InvalidYamlFileError extends CustomError {
filename: string;
constructor(filename: string);
}

View File

@@ -0,0 +1,11 @@
import { IacOutputMeta } from '../../../../lib/types';
import { IacOrgSettings } from './local-execution/types';
export interface GitRepository {
readonly path: string;
readRemoteUrl(): Promise<string | undefined>;
}
export interface GitRepositoryFinder {
findRepositoryForPath(path: string): Promise<GitRepository | undefined>;
}
export declare function buildMeta(repositoryFinder: GitRepositoryFinder, orgSettings: IacOrgSettings, projectRoot: string, remoteRepoUrl?: string, targetName?: string): Promise<IacOutputMeta>;
export declare function getProjectNameFromGitUrl(url: string): string;

View File

@@ -0,0 +1,35 @@
import { TestCommandResult } from '../../types';
import * as ora from 'ora';
import { IacFileInDirectory, IacOutputMeta, Options, TestOptions } from '../../../../lib/types';
import { IaCTestFlags } from './local-execution/types';
export declare function buildSpinner(options: IaCTestFlags): ora.Ora | undefined;
export declare function printHeader(options: IaCTestFlags): void;
export declare function buildOutput({ results, options, isIacShareCliResultsCustomRulesSupported, isIacCustomRulesEntitlementEnabled, iacOutputMeta, iacScanFailures, iacIgnoredIssuesCount, testSpinner, }: {
results: any[];
options: Options & TestOptions;
isIacShareCliResultsCustomRulesSupported: boolean;
isIacCustomRulesEntitlementEnabled: boolean;
iacOutputMeta: IacOutputMeta;
iacScanFailures: IacFileInDirectory[];
iacIgnoredIssuesCount: number;
testSpinner?: ora.Ora;
}): TestCommandResult;
export declare function buildShareResultsSummary({ orgName, projectName, options, isIacCustomRulesEntitlementEnabled, isIacShareCliResultsCustomRulesSupported, }: {
orgName: string;
projectName: string;
options: IaCTestFlags;
isIacCustomRulesEntitlementEnabled: boolean;
isIacShareCliResultsCustomRulesSupported: boolean;
}): string;
export declare function buildShareResultsSummaryIacPlus({ orgName, projectName, options, isIacCustomRulesEntitlementEnabled, isIacShareCliResultsCustomRulesSupported, }: {
orgName: string;
projectName: string;
options: IaCTestFlags;
isIacCustomRulesEntitlementEnabled: boolean;
isIacShareCliResultsCustomRulesSupported: boolean;
}): string;
export declare function buildShareResultsSummaryIacV2({ orgName, projectPublicId, }: {
orgName: string;
projectPublicId: string | undefined;
}): string;
export declare function shouldPrintShareResultsTip(options: IaCTestFlags): boolean;

View File

@@ -0,0 +1,11 @@
import { IacFileInDirectory, IacOutputMeta, Options, TestOptions } from '../../../../lib/types';
import * as ora from 'ora';
import { IacOrgSettings } from './local-execution/types';
import { OciRegistry } from './local-execution/rules/oci-registry';
export declare function scan(iacOrgSettings: IacOrgSettings, options: any, testSpinner: ora.Ora | undefined, paths: string[], orgPublicId: string, buildOciRules: () => OciRegistry, projectRoot: string, remoteRepoUrl?: string, targetName?: string): Promise<{
iacOutputMeta: IacOutputMeta;
iacScanFailures: IacFileInDirectory[];
iacIgnoredIssuesCount: number;
results: any[];
resultOptions: (Options & TestOptions)[];
}>;

View File

@@ -0,0 +1,2 @@
import { IaCTestFlags } from '../local-execution/types';
export declare function assertIacV2Options(options: IaCTestFlags): void;

View File

@@ -0,0 +1,3 @@
import { TestCommandResult } from '../../../types';
import { IaCTestFlags } from '../local-execution/types';
export declare function test(paths: string[], options: IaCTestFlags, iacNewEngine?: boolean): Promise<TestCommandResult>;

View File

@@ -0,0 +1,3 @@
import { MethodArgs } from '../../args';
import { TestCommandResult } from '../../commands/types';
export default function test(...args: MethodArgs): Promise<TestCommandResult>;

View File

@@ -0,0 +1,2 @@
import { Options, TestOptions } from '../../../lib/types';
export declare function setDefaultTestOptions<CommandOptions>(options: Options & CommandOptions): Options & TestOptions & CommandOptions;

View File

@@ -0,0 +1,2 @@
import { TestResult } from '../../../lib/snyk-test/legacy';
export declare function getPathWithOptionalProjectName(currPath: string, testResult: Pick<TestResult, 'projectName'>): string;

View File

@@ -0,0 +1,2 @@
import { TestOptions, Options } from '../../../lib/types';
export declare function validateCredentials(options: Options & TestOptions): void;

View File

@@ -0,0 +1,2 @@
import { TestOptions, Options } from '../../../lib/types';
export declare function validateTestOptions(options: TestOptions & Options): void;

View File

@@ -0,0 +1,40 @@
export type MethodResult = CommandResult | string | void;
export declare class CommandResult {
result: string;
constructor(result: string);
toString(): string;
getDisplayResults(): string;
}
export declare abstract class TestCommandResult extends CommandResult {
protected jsonResult: string;
protected sarifResult: string;
protected jsonData: {};
getJsonResult(): string;
getSarifResult(): string;
getJsonData(): Record<string, unknown>;
static createHumanReadableTestCommandResult(humanReadableResult: string, jsonResult: string, sarifResult?: string, jsonData?: Record<string, unknown>): HumanReadableTestCommandResult;
static createJsonTestCommandResult(stdout: string, jsonResult?: string, sarifResult?: string, jsonPayload?: Record<string, unknown>): JsonTestCommandResult;
}
declare class HumanReadableTestCommandResult extends TestCommandResult {
protected jsonResult: string;
protected sarifResult: string;
protected jsonData: {};
constructor(humanReadableResult: string, jsonResult: string, sarifResult?: string, jsonData?: Record<string, unknown>);
getJsonResult(): string;
getSarifResult(): string;
getJsonData(): Record<string, unknown>;
}
declare class JsonTestCommandResult extends TestCommandResult {
constructor(stdout: string, jsonResult?: string, sarifResult?: string, jsonData?: Record<string, unknown>);
getJsonResult(): string;
getSarifResult(): string;
}
export interface IgnoreMetadata {
reason: string;
expires: Date;
created: Date;
}
export interface IgnoreRulePathData {
[path: string]: IgnoreMetadata;
}
export {};

View File

@@ -0,0 +1,3 @@
import { MethodArgs } from '../args';
declare const _default: (...args: MethodArgs) => Promise<any>;
export default _default;

View File

@@ -0,0 +1 @@
export default function version(): Promise<string>;

View File

@@ -0,0 +1,2 @@
import { MethodArgs } from '../args';
export default function woof(...args: MethodArgs): void;

View File

@@ -0,0 +1,2 @@
import { MethodArgs } from '../../args';
export default function getWoof(args: MethodArgs): string;