Skip to content

Commit

Permalink
fix: allow escape characters in json parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
teodora-sandu committed Jan 10, 2022
1 parent 9b7f9a5 commit 3814c67
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -70,7 +70,7 @@
"dependencies": {
"@open-policy-agent/opa-wasm": "^1.6.0",
"@snyk/cli-interface": "2.11.0",
"@snyk/cloud-config-parser": "^1.12.0",
"@snyk/cloud-config-parser": "^1.13.1",
"@snyk/code-client": "^4.5.0",
"@snyk/dep-graph": "^1.27.1",
"@snyk/docker-registry-v2-client": "^2.6.1",
Expand Down
8 changes: 6 additions & 2 deletions src/cli/commands/test/iac-local-execution/yaml-parser.ts
@@ -1,11 +1,15 @@
import { CustomError } from '../../../../lib/errors';
import { getErrorStringCode } from './error-utils';
import { IaCErrorCodes, IacFileData } from './types';
import { parseFileContent } from '@snyk/cloud-config-parser';
import { ParserFileType, parseFileContent } from '@snyk/cloud-config-parser';

export function parseYAMLOrJSONFileData(fileData: IacFileData): any[] {
try {
return parseFileContent(fileData.fileContent);
// this function will always be called with the file types recognised by the parser
return parseFileContent(
fileData.fileContent,
fileData.fileType as ParserFileType,
);
} catch (e) {
if (fileData.fileType === 'json') {
throw new InvalidJsonFileError(fileData.filePath);
Expand Down
4 changes: 3 additions & 1 deletion src/lib/iac/constants.ts
@@ -1,11 +1,13 @@
import { ParserFileType } from '@snyk/cloud-config-parser';

export type IacProjectTypes =
| 'k8sconfig'
| 'terraformconfig'
| 'cloudformationconfig'
| 'armconfig'
| 'customconfig'
| 'multiiacconfig';
export type IacFileTypes = 'yaml' | 'yml' | 'json' | 'tf';
export type IacFileTypes = ParserFileType | 'tf';

export enum IacProjectType {
K8S = 'k8sconfig',
Expand Down

0 comments on commit 3814c67

Please sign in to comment.