"Fossies" - the Fresh Open Source Software Archive

Member "cli-1.1280.1/src/lib/iac/envelope-formatters.ts" (20 Feb 2024, 1207 Bytes) of package /linux/misc/snyk-cli-1.1280.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 import {
    2   IacShareResultsFormat,
    3   IaCTestFlags,
    4   PolicyMetadata,
    5 } from '../../cli/commands/test/iac/local-execution/types';
    6 import { GitTarget, NamedTarget, ScanResult } from '../ecosystems/types';
    7 import { Policy } from '../policy/find-and-load-policy';
    8 import { IacOutputMeta } from '../types';
    9 
   10 export function convertIacResultToScanResult(
   11   iacResult: IacShareResultsFormat,
   12   policy: Policy | undefined,
   13   meta: IacOutputMeta,
   14   options: IaCTestFlags,
   15 ): ScanResult {
   16   return {
   17     identity: {
   18       type: iacResult.projectType,
   19       targetFile: iacResult.targetFile,
   20     },
   21     facts: [],
   22     findings: iacResult.violatedPolicies.map((policy: PolicyMetadata) => {
   23       return {
   24         data: { metadata: policy, docId: policy.docId },
   25         type: 'iacIssue',
   26       };
   27     }),
   28     name: iacResult.projectName,
   29     target: buildTarget(meta, options),
   30     policy: policy?.toString() ?? '',
   31     targetReference: options?.['target-reference'],
   32   };
   33 }
   34 
   35 function buildTarget(
   36   meta: IacOutputMeta,
   37   options: IaCTestFlags,
   38 ): NamedTarget | GitTarget {
   39   if (meta.gitRemoteUrl) {
   40     return { remoteUrl: meta.gitRemoteUrl, name: options['target-name'] };
   41   }
   42   return { name: meta.projectName };
   43 }