Skip to content

Commit

Permalink
fix: use JSON.parse to avoid OOM error
Browse files Browse the repository at this point in the history
  • Loading branch information
teodora-sandu committed Dec 5, 2022
1 parent 7445bc9 commit 535225f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
14 changes: 7 additions & 7 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
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"dependencies": {
"@open-policy-agent/opa-wasm": "^1.6.0",
"@snyk/cli-interface": "2.11.0",
"@snyk/cloud-config-parser": "^1.14.3",
"@snyk/cloud-config-parser": "^1.14.5",
"@snyk/code-client": "^4.14.0",
"@snyk/dep-graph": "^1.27.1",
"@snyk/docker-registry-v2-client": "^2.7.3",
Expand Down
6 changes: 5 additions & 1 deletion src/cli/commands/test/iac/local-execution/yaml-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,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 } from '@snyk/cloud-config-parser/dist/yaml-parser';

export function parseYAMLOrJSONFileData(fileData: IacFileData): any[] {
try {
// this function will always be called with the file types recognised by the parser
return parseFileContent(fileData.fileContent);
return parseFileContent(
fileData.fileContent,
fileData.fileType as ParserFileType,
);
} catch (e) {
if (fileData.fileType === 'json') {
throw new InvalidJsonFileError(fileData.filePath);
Expand Down

0 comments on commit 535225f

Please sign in to comment.