Skip to content

Commit b613253

Browse files
committed
[PLUTO-1412] test init
1 parent 22105c0 commit b613253

File tree

13 files changed

+189
-11
lines changed

13 files changed

+189
-11
lines changed

.codacy/codacy.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
runtimes:
22
33
4-
54
tools:
65
76
87
98
109
11-
1210
13-

cmd/init.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ func buildRepositoryConfigurationFiles(token string) error {
275275
PyLint: "pylint",
276276
PMD: "pmd",
277277
DartAnalyzer: "dartanalyzer",
278+
Lizard: "lizard",
279+
Semgrep: "semgrep",
278280
}
279281

280282
// Generate languages configuration based on API tools response
@@ -384,52 +386,56 @@ func createToolFileConfigurations(tool tools.Tool, patternConfiguration []domain
384386
if err != nil {
385387
return fmt.Errorf("failed to create Trivy config: %v", err)
386388
}
389+
fmt.Println("Trivy configuration created based on Codacy settings")
387390
} else {
388391
err := createDefaultTrivyConfigFile(toolsConfigDir)
389392
if err != nil {
390393
return fmt.Errorf("failed to create default Trivy config: %v", err)
391394
}
392395
}
393-
fmt.Println("Trivy configuration created based on Codacy settings")
394396
case PMD:
395397
if len(patternConfiguration) > 0 {
396398
err := createPMDConfigFile(patternConfiguration, toolsConfigDir)
397399
if err != nil {
398400
return fmt.Errorf("failed to create PMD config: %v", err)
399401
}
402+
403+
fmt.Println("PMD configuration created based on Codacy settings")
400404
} else {
401405
err := createDefaultPMDConfigFile(toolsConfigDir)
402406
if err != nil {
403407
return fmt.Errorf("failed to create default PMD config: %v", err)
404408
}
405409
}
406-
fmt.Println("PMD configuration created based on Codacy settings")
410+
407411
case PyLint:
408412
if len(patternConfiguration) > 0 {
409413
err := createPylintConfigFile(patternConfiguration, toolsConfigDir)
410414
if err != nil {
411415
return fmt.Errorf("failed to create Pylint config: %v", err)
412416
}
417+
fmt.Println("Pylint configuration created based on Codacy settings")
413418
} else {
414419
err := createDefaultPylintConfigFile(toolsConfigDir)
415420
if err != nil {
416421
return fmt.Errorf("failed to create default Pylint config: %v", err)
417422
}
418423
}
419-
fmt.Println("Pylint configuration created based on Codacy settings")
420424
case DartAnalyzer:
421425
if len(patternConfiguration) > 0 {
422426
err := createDartAnalyzerConfigFile(patternConfiguration, toolsConfigDir)
423427
if err != nil {
424428
return fmt.Errorf("failed to create Dart Analyzer config: %v", err)
425429
}
430+
fmt.Println("Dart configuration created based on Codacy settings")
426431
}
427432
case Semgrep:
428433
if len(patternConfiguration) > 0 {
429434
err := createSemgrepConfigFile(patternConfiguration, toolsConfigDir)
430435
if err != nil {
431436
return fmt.Errorf("failed to create Semgrep config: %v", err)
432437
}
438+
fmt.Println("Semgrep configuration created based on Codacy settings")
433439
}
434440
case Lizard:
435441
createLizardConfigFile(toolsConfigDir, patternConfiguration)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Codacy CLI
2+
tools-configs/
3+
.gitignore
4+
cli-config.yaml
5+
logs/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mode: remote

integration-tests/init-with-token/expected/codacy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ runtimes:
22
33
44
tools:
5+
56
67
78
89
910
10-
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
tools:
2+
- name: pylint
3+
languages: [Python]
4+
extensions: [.py]
5+
- name: lizard
6+
languages: [Java, JavaScript, Python]
7+
extensions: [.java, .js, .jsm, .jsx, .mjs, .py, .vue]
8+
- name: pmd
9+
languages: [Java, JavaScript]
10+
extensions: [.java, .js, .jsm, .jsx, .mjs, .vue]
11+
- name: eslint
12+
languages: [JavaScript]
13+
extensions: [.js, .jsm, .jsx, .mjs, .vue]
14+
- name: trivy
15+
languages: [Multiple]
16+
extensions: []
17+
- name: semgrep
18+
languages: [Java, JavaScript, JSON, Python]
19+
extensions: [.java, .js, .jsm, .json, .jsx, .mjs, .py, .vue]
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
patterns:
2+
Lizard_ccn-minor:
3+
category: Complexity
4+
description: Check the Cyclomatic Complexity value of a function or logic block. If the threshold is not met, raise a Minor issue. The default threshold is 5.
5+
explanation: |-
6+
# Minor Cyclomatic Complexity control
7+
8+
Check the Cyclomatic Complexity value of a function or logic block. If the threshold is not met, raise a Minor issue. The default threshold is 4.
9+
id: Lizard_ccn-minor
10+
level: Info
11+
severityLevel: Info
12+
threshold: 5
13+
timeToFix: 5
14+
title: Minor Cyclomatic Complexity control
15+
Lizard_nloc-critical:
16+
category: Complexity
17+
description: Check the number of lines of code (without comments) in a function or logic block. If the threshold is not met, raise a Critical issue. The default threshold is 100.
18+
explanation: |-
19+
# Critical NLOC control - Number of Lines of Code (without comments)
20+
21+
Check the number of lines of code (without comments) in a function or logic block. If the threshold is not met, raise a Critical issue. The default threshold is 100.
22+
id: Lizard_nloc-critical
23+
level: Error
24+
severityLevel: Error
25+
threshold: 100
26+
timeToFix: 5
27+
title: Critical NLOC control - Number of Lines of Code (without comments)
28+
Lizard_nloc-medium:
29+
category: Complexity
30+
description: Check the number of lines of code (without comments) in a function. If the threshold is not met, raise a Medium issue. The default threshold is 50.
31+
explanation: |-
32+
# Medium NLOC control - Number of Lines of Code (without comments)
33+
34+
Check the number of lines of code (without comments) in a function. If the threshold is not met, raise a Medium issue. The default threshold is 50.
35+
id: Lizard_nloc-medium
36+
level: Warning
37+
severityLevel: Warning
38+
threshold: 50
39+
timeToFix: 5
40+
title: Medium NLOC control - Number of Lines of Code (without comments)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[MASTER]
2+
ignore=CVS
3+
persistent=yes
4+
load-plugins=
5+
6+
[MESSAGES CONTROL]
7+
disable=all
8+
enable=E1124,E1130,E1133
9+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Codacy PMD Ruleset"
3+
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
6+
<description>Codacy PMD Ruleset</description>
7+
8+
<rule ref="category/apex/design.xml/ExcessivePublicCount"/>
9+
<rule ref="category/java/bestpractices.xml/JUnitTestsShouldIncludeAssert"/>
10+
<rule ref="category/java/codestyle.xml/ShortMethodName"/>
11+
<rule ref="category/java/errorprone.xml/AssignmentToNonFinalStatic"/>
12+
</ruleset>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
rules:
2+
- id: apex.lang.security.ncino.endpoints.namedcredentialsconstantmatch.named-credentials-constant-match
3+
languages:
4+
- apex
5+
message: Named Credentials (and callout endpoints) should be used instead of hard-coding credentials. 1. Hard-coded credentials are hard to maintain when mixed in with application code. 2. It is particularly hard to update hard-coded credentials when they are used amongst different classes. 3. Granting a developer access to the codebase means granting knowledge of credentials, and thus keeping a two-level access is not possible. 4. Using different credentials for different environments is troublesome and error-prone.
6+
metadata:
7+
category: security
8+
confidence: HIGH
9+
cwe:
10+
- 'CWE-540: Inclusion of Sensitive Information in Source Code'
11+
impact: HIGH
12+
likelihood: LOW
13+
references:
14+
- https://cwe.mitre.org/data/definitions/540.html
15+
subcategory:
16+
- vuln
17+
technology:
18+
- salesforce
19+
min-version: 1.44.0
20+
mode: taint
21+
pattern-sinks:
22+
- patterns:
23+
- pattern: req.setHeader($X, ...);
24+
- focus-metavariable: $X
25+
pattern-sources:
26+
- pattern: '...String $X = ''Authorization'';'
27+
severity: ERROR
28+
- id: clojure.lang.security.use-of-md5.use-of-md5
29+
languages:
30+
- clojure
31+
message: MD5 hash algorithm detected. This is not collision resistant and leads to easily-cracked password hashes. Replace with current recommended hashing algorithms.
32+
metadata:
33+
author: Gabriel Marquet <[email protected]>
34+
category: security
35+
confidence: HIGH
36+
cwe:
37+
- 'CWE-328: Use of Weak Hash'
38+
impact: HIGH
39+
likelihood: MEDIUM
40+
owasp:
41+
- A03:2017 - Sensitive Data Exposure
42+
- A02:2021 - Cryptographic Failures
43+
references:
44+
- https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html
45+
- https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html
46+
source-rule-url: https://github.com/clj-holmes/clj-holmes-rules/blob/main/security/weak-hash-function-md5.yml
47+
subcategory:
48+
- vuln
49+
technology:
50+
- clojure
51+
pattern-either:
52+
- pattern: (MessageDigest/getInstance "MD5")
53+
- pattern: (MessageDigest/getInstance MessageDigestAlgorithms/MD5)
54+
- pattern: (MessageDigest/getInstance org.apache.commons.codec.digest.MessageDigestAlgorithms/MD5)
55+
- pattern: (java.security.MessageDigest/getInstance "MD5")
56+
- pattern: (java.security.MessageDigest/getInstance MessageDigestAlgorithms/MD5)
57+
- pattern: (java.security.MessageDigest/getInstance org.apache.commons.codec.digest.MessageDigestAlgorithms/MD5)
58+
severity: WARNING
59+
- id: codacy.generic.plsql.empty-strings
60+
languages:
61+
- generic
62+
message: Empty strings can lead to unexpected behavior and should be handled carefully.
63+
metadata:
64+
category: security
65+
confidence: MEDIUM
66+
description: Detects empty strings in the code which might cause issues or bugs.
67+
impact: MEDIUM
68+
pattern: $VAR VARCHAR2($LENGTH) := '';
69+
severity: WARNING

0 commit comments

Comments
 (0)