-
Notifications
You must be signed in to change notification settings - Fork 560
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1719 from snyk/fix/file-content-in-iac-analytics
fix: include file content in iac analytics
- Loading branch information
Showing
7 changed files
with
125 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# NOTE: Kubernetes file with no issues used to detect | ||
# if our analytics/logs contain file content. | ||
# PRIVATE_FILE_CONTENT_CHECK | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: example | ||
spec: | ||
containers: | ||
- name: example | ||
image: example:latest | ||
securityContext: | ||
privileged: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
jest.mock('../../src/cli/commands/test/iac-local-execution/local-cache'); | ||
jest.mock('../../src/cli/commands/test/iac-local-execution/file-loader'); | ||
jest.mock('../../src/cli/commands/test/iac-local-execution/file-parser', () => { | ||
const { IacProjectType } = require('../../src/lib/iac/constants'); | ||
const { | ||
EngineType, | ||
} = require('../../src/cli/commands/test/iac-local-execution/types'); | ||
const parsedFiles: IacFileParsed[] = [ | ||
{ | ||
engineType: EngineType.Terraform, | ||
fileContent: 'FAKE_FILE_CONTENT', | ||
jsonContent: {}, | ||
filePath: './storage/storage.tf', | ||
fileType: 'tf', | ||
failureReason: 'Mock Test', | ||
projectType: IacProjectType.TERRAFORM, | ||
}, | ||
]; | ||
return { | ||
parseFiles: async () => ({ parsedFiles, failedFiles: [] }), | ||
}; | ||
}); | ||
jest.mock( | ||
'../../src/cli/commands/test/iac-local-execution/file-scanner', | ||
() => { | ||
return { | ||
scanFiles: async () => [], | ||
}; | ||
}, | ||
); | ||
jest.mock('../../src/lib/detect', () => ({ | ||
isLocalFolder: () => true, | ||
})); | ||
|
||
import { test } from '../../src/cli/commands/test/iac-local-execution'; | ||
import { | ||
IacFileParsed, | ||
IacOptionFlags, | ||
} from '../../src/cli/commands/test/iac-local-execution/types'; | ||
import { IacProjectType } from '../../src/lib/iac/constants'; | ||
|
||
describe('test()', () => { | ||
it('extends the options object with iacDirFiles when a local directory is provided', async () => { | ||
const opts: IacOptionFlags = {}; | ||
await test('./storage/', opts); | ||
|
||
expect(opts.iacDirFiles).toEqual([ | ||
{ | ||
filePath: './storage/storage.tf', | ||
fileType: 'tf', | ||
failureReason: 'Mock Test', | ||
projectType: IacProjectType.TERRAFORM, | ||
}, | ||
]); | ||
expect(opts.iacDirFiles).not.toEqual( | ||
expect.arrayContaining([ | ||
{ | ||
fileContent: 'FAKE_FILE_CONTENT', | ||
jsonContent: {}, | ||
}, | ||
]), | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters