@contrast/contrast 1.0.23 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -138
- package/dist/audit/languageAnalysisEngine/sendSnapshot.js +2 -19
- package/dist/audit/save.js +6 -1
- package/dist/cliConstants.js +49 -0
- package/dist/commands/audit/auditController.js +2 -1
- package/dist/commands/audit/help.js +2 -3
- package/dist/commands/audit/processAudit.js +2 -0
- package/dist/commands/audit/saveFile.js +5 -1
- package/dist/commands/{fingerprint → github}/processFingerprint.js +6 -2
- package/dist/commands/github/projectGroup.js +174 -0
- package/dist/commands/github/repoServices.js +70 -0
- package/dist/common/HTTPClient.js +165 -13
- package/dist/common/errorHandling.js +1 -1
- package/dist/constants/constants.js +3 -5
- package/dist/constants/locales.js +7 -3
- package/dist/index.js +4 -4
- package/dist/lambda/lambda.js +3 -1
- package/dist/scaAnalysis/common/commonReportingFunctionsSca.js +3 -3
- package/dist/scaAnalysis/common/scaServicesUpload.js +77 -7
- package/dist/scaAnalysis/common/treeUpload.js +19 -5
- package/dist/scaAnalysis/go/goAnalysis.js +6 -1
- package/dist/scaAnalysis/java/index.js +6 -1
- package/dist/scaAnalysis/javascript/index.js +5 -2
- package/dist/scaAnalysis/legacy/legacyFlow.js +33 -0
- package/dist/scaAnalysis/php/index.js +8 -2
- package/dist/scaAnalysis/processServicesFlow.js +39 -0
- package/dist/scaAnalysis/python/analysis.js +10 -4
- package/dist/scaAnalysis/python/index.js +6 -1
- package/dist/scaAnalysis/repoMode/index.js +2 -2
- package/dist/scaAnalysis/ruby/analysis.js +10 -1
- package/dist/scaAnalysis/ruby/index.js +6 -1
- package/dist/scaAnalysis/scaAnalysis.js +47 -25
- package/dist/scan/autoDetection.js +47 -4
- package/dist/scan/fileUtils.js +5 -4
- package/dist/utils/commonApi.js +26 -1
- package/dist/utils/settingsHelper.js +14 -0
- package/package.json +8 -5
- package/src/audit/languageAnalysisEngine/sendSnapshot.js +3 -22
- package/src/audit/save.js +10 -1
- package/src/cliConstants.js +52 -0
- package/src/commands/audit/auditController.js +2 -1
- package/src/commands/audit/help.js +2 -3
- package/src/commands/audit/processAudit.js +2 -0
- package/src/commands/audit/saveFile.js +6 -1
- package/src/commands/{fingerprint → github}/processFingerprint.js +8 -2
- package/src/commands/github/projectGroup.js +198 -0
- package/src/commands/github/repoServices.js +80 -0
- package/src/common/HTTPClient.js +221 -13
- package/src/common/errorHandling.js +2 -2
- package/src/constants/constants.js +3 -5
- package/src/constants/locales.js +9 -3
- package/src/index.ts +5 -5
- package/src/lambda/lambda.ts +3 -1
- package/src/lambda/lambdaUtils.ts +1 -1
- package/src/scaAnalysis/common/commonReportingFunctionsSca.js +3 -3
- package/src/scaAnalysis/common/scaServicesUpload.js +92 -7
- package/src/scaAnalysis/common/treeUpload.js +20 -5
- package/src/scaAnalysis/go/goAnalysis.js +6 -1
- package/src/scaAnalysis/java/index.js +6 -1
- package/src/scaAnalysis/javascript/index.js +6 -4
- package/src/scaAnalysis/legacy/legacyFlow.js +48 -0
- package/src/scaAnalysis/php/index.js +8 -2
- package/src/scaAnalysis/processServicesFlow.js +61 -0
- package/src/scaAnalysis/python/analysis.js +10 -4
- package/src/scaAnalysis/python/index.js +6 -1
- package/src/scaAnalysis/repoMode/index.js +2 -2
- package/src/scaAnalysis/ruby/analysis.js +11 -1
- package/src/scaAnalysis/ruby/index.js +6 -1
- package/src/scaAnalysis/scaAnalysis.js +61 -37
- package/src/scan/autoDetection.js +50 -5
- package/src/scan/fileUtils.js +5 -4
- package/src/utils/commonApi.js +29 -1
- package/src/utils/settingsHelper.js +16 -0
- /package/dist/commands/{fingerprint → github}/fingerprintConfig.js +0 -0
- /package/src/commands/{fingerprint → github}/fingerprintConfig.js +0 -0
|
@@ -1,18 +1,62 @@
|
|
|
1
1
|
const i18n = require('i18n')
|
|
2
2
|
const fileFinder = require('./fileUtils')
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const {
|
|
4
|
+
supportedLanguages: { JAVA, GO, PYTHON, RUBY, JAVASCRIPT, NODE, PHP, DOTNET }
|
|
5
|
+
} = require('../constants/constants')
|
|
6
|
+
const autoDetectFingerprintInfo = async (filePath, depth, config) => {
|
|
5
7
|
let complexObj = await fileFinder.findAllFiles(filePath, depth)
|
|
6
8
|
let result = []
|
|
7
9
|
let count = 0
|
|
8
10
|
complexObj.forEach(i => {
|
|
9
11
|
count++
|
|
10
|
-
result.push({
|
|
12
|
+
result.push({
|
|
13
|
+
filePath: i,
|
|
14
|
+
id: count.toString(),
|
|
15
|
+
repositoryId: config.repositoryId
|
|
16
|
+
})
|
|
11
17
|
})
|
|
12
18
|
|
|
13
19
|
return result
|
|
14
20
|
}
|
|
15
21
|
|
|
22
|
+
const detectPackageManager = async array => {
|
|
23
|
+
array.forEach(i => {
|
|
24
|
+
if (i.filePath.includes('pom.xml')) {
|
|
25
|
+
i['language'] = JAVA
|
|
26
|
+
i['packageManager'] = 'MAVEN'
|
|
27
|
+
}
|
|
28
|
+
if (i.filePath.includes('build.gradle.kts')) {
|
|
29
|
+
i['language'] = JAVA
|
|
30
|
+
i['packageManager'] = 'GRADLE'
|
|
31
|
+
}
|
|
32
|
+
if (i.filePath.includes('build.gradle')) {
|
|
33
|
+
i['language'] = JAVA
|
|
34
|
+
i['packageManager'] = 'GRADLE'
|
|
35
|
+
}
|
|
36
|
+
if (i.filePath.includes('package-lock.json')) {
|
|
37
|
+
i['language'] = JAVASCRIPT
|
|
38
|
+
i['packageManager'] = 'NPM'
|
|
39
|
+
}
|
|
40
|
+
if (i.filePath.includes('yarn.lock')) {
|
|
41
|
+
i['language'] = JAVASCRIPT
|
|
42
|
+
i['packageManager'] = 'YARN'
|
|
43
|
+
}
|
|
44
|
+
if (i.filePath.includes('Pipfile')) {
|
|
45
|
+
i['language'] = PYTHON
|
|
46
|
+
}
|
|
47
|
+
if (i.filePath.includes('csproj')) {
|
|
48
|
+
i['language'] = DOTNET
|
|
49
|
+
}
|
|
50
|
+
if (i.filePath.includes('Gemfile')) {
|
|
51
|
+
i['language'] = RUBY
|
|
52
|
+
}
|
|
53
|
+
if (i.filePath.includes('go.mod')) {
|
|
54
|
+
i['language'] = GO
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
return array
|
|
58
|
+
}
|
|
59
|
+
|
|
16
60
|
const autoDetectFileAndLanguage = async configToUse => {
|
|
17
61
|
const entries = await fileFinder.findFile()
|
|
18
62
|
|
|
@@ -67,7 +111,7 @@ const dealWithMultiJava = filesFound => {
|
|
|
67
111
|
let hasMultiJava =
|
|
68
112
|
filesFound.filter(data => {
|
|
69
113
|
return (
|
|
70
|
-
Object.keys(data)[0] ===
|
|
114
|
+
Object.keys(data)[0] === JAVA &&
|
|
71
115
|
Object.values(data)[0].includes('build.gradle') &&
|
|
72
116
|
Object.values(data)[0].includes('pom.xml')
|
|
73
117
|
)
|
|
@@ -119,5 +163,6 @@ module.exports = {
|
|
|
119
163
|
autoDetectAuditFilesAndLanguages,
|
|
120
164
|
errorOnAuditFileDetection,
|
|
121
165
|
autoDetectFingerprintInfo,
|
|
122
|
-
dealWithMultiJava
|
|
166
|
+
dealWithMultiJava,
|
|
167
|
+
detectPackageManager
|
|
123
168
|
}
|
package/src/scan/fileUtils.js
CHANGED
|
@@ -18,6 +18,7 @@ const findAllFiles = async (filePath, depth = 2) => {
|
|
|
18
18
|
'**/build.gradle',
|
|
19
19
|
'**/build.gradle.kts',
|
|
20
20
|
'**/package.json',
|
|
21
|
+
'**/yarn.lock',
|
|
21
22
|
'**/Pipfile',
|
|
22
23
|
'**/*.csproj',
|
|
23
24
|
'**/Gemfile',
|
|
@@ -38,19 +39,19 @@ const findAllFiles = async (filePath, depth = 2) => {
|
|
|
38
39
|
return []
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
const findFilesJava = async (languagesFound, filePath) => {
|
|
42
|
+
const findFilesJava = async (languagesFound, filePath, depth = 1) => {
|
|
42
43
|
const result = await fg(
|
|
43
44
|
['**/pom.xml', '**/build.gradle', '**/build.gradle.kts'],
|
|
44
45
|
{
|
|
45
46
|
dot: false,
|
|
46
|
-
deep:
|
|
47
|
+
deep: depth,
|
|
47
48
|
onlyFiles: true,
|
|
48
49
|
cwd: filePath ? filePath : process.cwd()
|
|
49
50
|
}
|
|
50
51
|
)
|
|
51
52
|
|
|
52
53
|
if (result.length > 0) {
|
|
53
|
-
return languagesFound.push({ JAVA: result })
|
|
54
|
+
return languagesFound.push({ JAVA: result, language: 'JAVA' })
|
|
54
55
|
}
|
|
55
56
|
return languagesFound
|
|
56
57
|
}
|
|
@@ -67,7 +68,7 @@ const findFilesJavascript = async (languagesFound, filePath) => {
|
|
|
67
68
|
)
|
|
68
69
|
|
|
69
70
|
if (result.length > 0) {
|
|
70
|
-
return languagesFound.push({ JAVASCRIPT: result })
|
|
71
|
+
return languagesFound.push({ JAVASCRIPT: result, language: 'JAVASCRIPT' })
|
|
71
72
|
}
|
|
72
73
|
return languagesFound
|
|
73
74
|
}
|
package/src/utils/commonApi.js
CHANGED
|
@@ -12,7 +12,33 @@ const {
|
|
|
12
12
|
parametersError,
|
|
13
13
|
invalidHostNameError
|
|
14
14
|
} = require('../common/errorHandling')
|
|
15
|
+
const { performance } = require('perf_hooks')
|
|
16
|
+
const requestUtils = require('./requestUtils')
|
|
17
|
+
const oraFunctions = require('./oraWrapper')
|
|
15
18
|
|
|
19
|
+
const getTimeout = config => {
|
|
20
|
+
if (config.timeout) {
|
|
21
|
+
return config.timeout
|
|
22
|
+
} else {
|
|
23
|
+
if (config.verbose) {
|
|
24
|
+
console.log('Timeout set to 5 minutes')
|
|
25
|
+
}
|
|
26
|
+
return 300
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const handleTimeout = (startTime, timeout, reportSpinner) => {
|
|
31
|
+
const endTime = performance.now() - startTime
|
|
32
|
+
if (requestUtils.millisToSeconds(endTime) > timeout) {
|
|
33
|
+
oraFunctions.failSpinner(
|
|
34
|
+
reportSpinner,
|
|
35
|
+
'Contrast audit timed out at the specified timeout of ' +
|
|
36
|
+
timeout +
|
|
37
|
+
' seconds.'
|
|
38
|
+
)
|
|
39
|
+
throw new Error('You can update the timeout using --timeout')
|
|
40
|
+
}
|
|
41
|
+
}
|
|
16
42
|
const handleResponseErrors = (res, api) => {
|
|
17
43
|
if (res.statusCode === 400) {
|
|
18
44
|
api === 'catalogue' ? badRequestError(true) : badRequestError(false)
|
|
@@ -71,5 +97,7 @@ module.exports = {
|
|
|
71
97
|
getValidHost: getValidHost,
|
|
72
98
|
getProtocol: getProtocol,
|
|
73
99
|
handleResponseErrors: handleResponseErrors,
|
|
74
|
-
getHttpClient: getHttpClient
|
|
100
|
+
getHttpClient: getHttpClient,
|
|
101
|
+
handleTimeout: handleTimeout,
|
|
102
|
+
getTimeout: getTimeout
|
|
75
103
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const generalAPI = require('./generalAPI')
|
|
2
|
+
const { SAAS } = require('../constants/constants')
|
|
3
|
+
|
|
4
|
+
const getSettings = async config => {
|
|
5
|
+
config.isEOP =
|
|
6
|
+
(await generalAPI.getMode(config)).toUpperCase() === SAAS ? false : true
|
|
7
|
+
|
|
8
|
+
if (config.legacy === undefined) {
|
|
9
|
+
config.legacy = config.isEOP
|
|
10
|
+
}
|
|
11
|
+
return config
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
getSettings
|
|
16
|
+
}
|
|
File without changes
|
|
File without changes
|