Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cwe): add cwe into sarif report and KICS CLI results #6845

Merged
merged 58 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
4eaedbe
feat(cwe): add cwe into sarif report and KICS CLI results
ArturRibeiro-CX Jan 4, 2024
4cf3afd
feat(cwe): add cwe into sarif report and KICS CLI results
ArturRibeiro-CX Jan 4, 2024
90bb750
feat(cwe): add cwe into sarif report and KICS CLI results
ArturRibeiro-CX Jan 4, 2024
df81fab
feat(cwe): add cwe into sarif report and KICS CLI results
ArturRibeiro-CX Jan 5, 2024
9636be8
feat(cwe): add cwe into sarif report and KICS CLI results
ArturRibeiro-CX Jan 5, 2024
1722b58
Merge branch 'master' into cwe
gabriel-cx Jan 5, 2024
20cd3c4
added e2e test for cwe field in sarif report format
ArturRibeiro-CX Jan 5, 2024
060b459
Merge branch 'master' of https://github.com/Checkmarx/kics into cwe
ArturRibeiro-CX Jan 5, 2024
4fb60c3
Merge branch 'cwe' of https://github.com/Checkmarx/kics into cwe
ArturRibeiro-CX Jan 5, 2024
33a15ed
added e2e test for cwe field in sarif report format
ArturRibeiro-CX Jan 5, 2024
18f9dc9
fix cyclonedx commit on wrong branch
ArturRibeiro-CX Jan 8, 2024
4698101
fix cyclonedx commit on wrong branch
ArturRibeiro-CX Jan 8, 2024
aeec710
fix cyclonedx commit on wrong branch and remove comments
ArturRibeiro-CX Jan 8, 2024
4a6ffda
Merge branch 'master' into cwe
gabriel-cx Jan 9, 2024
ca788e3
remove cwe from sarifMessage
ArturRibeiro-CX Jan 9, 2024
b15da83
changes to addition of cwe into sarif report and KICS CLI results
ArturRibeiro-CX Jan 19, 2024
cfa3df8
fixing potential file inclusion via variable error by cleaning paths
ArturRibeiro-CX Jan 19, 2024
6aad350
linting issues fixed
ArturRibeiro-CX Jan 19, 2024
5d26283
fixing linting issues
ArturRibeiro-CX Jan 19, 2024
1fd0d35
Merge branch 'master' of https://github.com/Checkmarx/kics into cwe
ArturRibeiro-CX Jan 19, 2024
3ebc66c
fix linting e2e and naming
ArturRibeiro-CX Jan 19, 2024
842f2e4
fix linting problems
ArturRibeiro-CX Jan 19, 2024
a516a11
fixing linting
ArturRibeiro-CX Jan 19, 2024
b548e42
fixing linting problem sarif.go
ArturRibeiro-CX Jan 19, 2024
8cd6e4b
change to result-sarif.json to accept the new sarif format
ArturRibeiro-CX Jan 19, 2024
30c5e55
changes to result-sarif-required.json to accept new sarif format
ArturRibeiro-CX Jan 19, 2024
e797987
e2e for sarif report format
ArturRibeiro-CX Jan 19, 2024
30ae8bf
change bool to boolean type in result-sarif.json
ArturRibeiro-CX Jan 19, 2024
f4c5c04
addition of fullDescription text field as empty string to fix e2e error
ArturRibeiro-CX Jan 19, 2024
c854f72
fixing fullDescription text required issue on e2e
ArturRibeiro-CX Jan 19, 2024
9a827a1
Merge branch 'master' of https://github.com/Checkmarx/kics into cwe
ArturRibeiro-CX Jan 19, 2024
cfa1383
fullDescription equal to shortDescription in taxonomies when empty an…
ArturRibeiro-CX Jan 19, 2024
f23a0f9
last fix e2e result sarif files
ArturRibeiro-CX Jan 19, 2024
dfe8739
add path to uri locations in E2E_CLI_080 and E2E_CLI_070
ArturRibeiro-CX Jan 22, 2024
a256ac0
fix paths E2E_CLI 069 and 070
ArturRibeiro-CX Jan 22, 2024
cedc806
add new files to Dockerfile and error verification to sarif.go
ArturRibeiro-CX Jan 22, 2024
49af1ae
fix addition of new files to Dockerfile
ArturRibeiro-CX Jan 22, 2024
8770998
relationship target changed from array to object
ArturRibeiro-CX Jan 23, 2024
7786f26
fix to index being required in relationships as CWE does not require …
ArturRibeiro-CX Jan 23, 2024
1cd8a84
fix to name and guid not being required and lenght of this parameters
ArturRibeiro-CX Jan 23, 2024
ffebe5b
fix id lenght when parameters are empty in relationships
ArturRibeiro-CX Jan 23, 2024
8ba89af
changes to sarif report cwe field empty or not and according files
ArturRibeiro-CX Jan 24, 2024
655febf
change to name being required on toolComponent and not target in rela…
ArturRibeiro-CX Jan 24, 2024
9c48780
add test to printer with CWE field
ArturRibeiro-CX Jan 24, 2024
0e4a197
Merge branch 'master' into cwe
ArturRibeiro-CX Jan 24, 2024
9da0e25
add test case for vulnerability builder test with CWE field
ArturRibeiro-CX Jan 24, 2024
6138693
add test to summary_test
ArturRibeiro-CX Jan 25, 2024
86ef7e0
changes to summary_test to have CWE complete
ArturRibeiro-CX Jan 25, 2024
f5ca9b6
add tests for taxonomies and taxa fields in sarif report
ArturRibeiro-CX Jan 25, 2024
8f40e37
add one more test to taxonomies definition with no CWE field
ArturRibeiro-CX Jan 25, 2024
5634af0
added test for reading the csv file with CWE info correctly
ArturRibeiro-CX Jan 25, 2024
85b338f
add new cwe_csv to all dockerfiles in docker directory
ArturRibeiro-CX Jan 26, 2024
646f5a5
test Dockerfile change by coppying all directory
ArturRibeiro-CX Jan 29, 2024
82c3962
changes to all dockerfile necessary to copy cwe_csv directory without…
ArturRibeiro-CX Jan 29, 2024
8670aaa
fix typo replacing Run with RUN on Dockerfile in kics root
ArturRibeiro-CX Jan 29, 2024
30846f7
remove '/' from COPY statement in Dockerfiles to maintain the same logic
ArturRibeiro-CX Jan 29, 2024
6c4c407
Merge branch 'master' into cwe
asofsilva Feb 5, 2024
1fafda4
Merge branch 'master' into cwe
gabriel-cx Feb 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ junit-results.xml

# Sarif files
*.sarif
!e2e/fixtures/E2E_CLI_079_RESULT.sarif
!e2e/fixtures/E2E_CLI_080_RESULT.sarif

# coverage report
coverage.html
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ FROM alpine:3.19
ENV TERM xterm-256color

# Install additional components from Alpine
Run apk update --no-cache \
RUN apk update --no-cache \
&& apk add --no-cache \
gcompat~=1.1.0 \
git~=2.43
Expand Down Expand Up @@ -66,6 +66,7 @@ RUN wget https://github.com/GoogleCloudPlatform/terraformer/releases/download/0.
# kics-scan ignore-line
COPY --from=build_env /app/bin/kics /app/bin/kics
COPY --from=build_env /app/assets/queries /app/bin/assets/queries
COPY --from=build_env /app/assets/cwe_csv /app/bin/assets/cwe_csv
COPY --from=build_env /app/assets/libraries/* /app/bin/assets/libraries/

WORKDIR /app/bin
Expand Down
400 changes: 400 additions & 0 deletions assets/cwe_csv/Software-Development-CWE.csv

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions assets/cwe_csv/cwe_taxonomies_latest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"taxonomies":
{
"downloadUri": "https://cwe.mitre.org/data/xml/cwec_v4.13.xml.zip",
"guid": "1489b0c4-d7ce-4d31-af66-6382a01202e3",
"informationUri": "https://cwe.mitre.org/data/published/cwe_v4.13.pdf",
"isComprehensive": true,
"language": "en",
"minimumRequiredLocalizedDataSemanticVersion": "4.13",
"name": "CWE",
"organization": "MITRE",
"releaseDateUtc": "2023-10-26",
"shortDescription": {
"text": "The MITRE Common Weakness Enumeration"
},
"fullDescription": {
"text": "The MITRE Common Weakness Enumeration"
},
"taxa": []
}
}
1 change: 1 addition & 0 deletions docker/Dockerfile.apispec
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ COPY --from=build_env /app/assets/libraries/common /app/bin/assets/libraries/com
COPY --from=build_env /app/assets/libraries/openapi /app/bin/assets/libraries/openapi
COPY --from=build_env /app/assets/queries/openAPI /app/bin/assets/queries/openAPI
COPY --from=build_env /app/assets/queries/common /app/bin/assets/queries/common
COPY --from=build_env /app/assets/cwe_csv /app/bin/assets/cwe_csv

WORKDIR /app/bin

Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile.apispec.debian
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ COPY --from=build_env /app/assets/libraries/common /app/bin/assets/libraries/com
COPY --from=build_env /app/assets/libraries/openapi /app/bin/assets/libraries/openapi
COPY --from=build_env /app/assets/queries/openAPI /app/bin/assets/queries/openAPI
COPY --from=build_env /app/assets/queries/common /app/bin/assets/queries/common
COPY --from=build_env /app/assets/cwe_csv /app/bin/assets/cwe_csv

WORKDIR /app/bin

Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ RUN mkdir ~/.terraform.d && mkdir ~/.terraform.d/plugins && mkdir ~/.terraform.d

COPY --from=build_env /app/bin/kics /app/bin/kics
COPY --from=build_env /app/assets/queries /app/bin/assets/queries
COPY --from=build_env /app/assets/cwe_csv /app/bin/assets/cwe_csv
COPY --from=build_env /app/assets/libraries/* /app/bin/assets/libraries/

WORKDIR /app/bin
Expand Down
306 changes: 306 additions & 0 deletions e2e/fixtures/E2E_CLI_079_RESULT.sarif
Original file line number Diff line number Diff line change
@@ -0,0 +1,306 @@
{
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
"version": "2.1.0",
"runs": [
{
"tool": {
"driver": {
"name": "KICS",
"version": "development",
"fullName": "Keeping Infrastructure as Code Secure",
"informationUri": "https://www.kics.io/",
"rules": [
{
"id": "20f14e1a-a899-4e79-9f09-b6a84cd4649b",
"name": "Run Block Injection",
"shortDescription": {
"text": "Run Block Injection"
},
"fullDescription": {
"text": "GitHub Actions workflows can be triggered by a variety of events. Every workflow trigger is provided with a GitHub context that contains information about the triggering event, such as which user triggered it, the branch name, and other event context details. Some of this event data, like the base repository name, hash value of a changeset, or pull request number, is unlikely to be controlled or used for injection by the user that triggered the event."
},
"defaultConfiguration": {
"level": "error"
},
"helpUri": "https://securitylab.github.com/research/github-actions-untrusted-input/",
"relationships": [
{
"target": {
"id": "CAT007",
"index": 14,
"toolComponent": {
"name": "Categories",
"guid": "58cdcc6f-fe41-4724-bfb3-131a93df4c3f"
}
}
},
{
"target": {
"id": "22",
"guid": "81713b3d-740e-4d67-8003-27068b8214b4",
"toolComponent": {
"name": "CWE",
"guid": "1489b0c4-d7ce-4d31-af66-6382a01202e3"
}
}
}
]
}
]
}
},
"results": [
{
"ruleId": "20f14e1a-a899-4e79-9f09-b6a84cd4649b",
"ruleIndex": 0,
"kind": "fail",
"message": {
"text": "Run block contains dangerous input controlled by user.",
"properties": {
"platform": "CICD"
}
},
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"uri": "path\\test\\fixtures\\test_sarif_cwe_report\\run_block_injection\\test\\positive1.yaml"
},
"region": {
"startLine": 10
}
}
}
]
},
{
"ruleId": "20f14e1a-a899-4e79-9f09-b6a84cd4649b",
"ruleIndex": 0,
"kind": "fail",
"message": {
"text": "Run block contains dangerous input controlled by user.",
"properties": {
"platform": "CICD"
}
},
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"uri": "path\\test\\fixtures\\test_sarif_cwe_report\\run_block_injection\\test\\positive1.yaml"
},
"region": {
"startLine": 10
}
}
}
]
}
],
"taxonomies": [
{
"guid": "58cdcc6f-fe41-4724-bfb3-131a93df4c3f",
"name": "Categories",
"fullDescription": {
"text": "This taxonomy contains the types an issue can assume"
},
"shortDescription": {
"text": "Vulnerabilities categories"
},
"taxa": [
{
"name": "Undefined Category",
"id": "CAT000",
"shortDescription": {
"text": "Category is not defined"
},
"fullDescription": {
"text": "Category is not defined"
}
},
{
"name": "Insecure Defaults",
"id": "CAT008",
"shortDescription": {
"text": "Configurations that are insecure by default"
},
"fullDescription": {
"text": "Configurations that are insecure by default"
}
},
{
"name": "Structure and Semantics",
"id": "CAT014",
"shortDescription": {
"text": "Malformed document structure or inadequate semantics"
},
"fullDescription": {
"text": "Malformed document structure or inadequate semantics"
}
},
{
"name": "Availability",
"id": "CAT002",
"shortDescription": {
"text": "Reliability and Scalability"
},
"fullDescription": {
"text": "Reliability and Scalability"
}
},
{
"name": "Build Process",
"id": "CAT005",
"shortDescription": {
"text": "Insecure configurations when building/deploying"
},
"fullDescription": {
"text": "Insecure configurations when building/deploying"
}
},
{
"name": "Secret Management",
"id": "CAT012",
"shortDescription": {
"text": "Secret and Key management"
},
"fullDescription": {
"text": "Secret and Key management"
}
},
{
"name": "Supply-Chain",
"id": "CAT013",
"shortDescription": {
"text": "Dependency version management"
},
"fullDescription": {
"text": "Dependency version management"
}
},
{
"name": "Backup",
"id": "CAT003",
"shortDescription": {
"text": "Survivability and Recovery"
},
"fullDescription": {
"text": "Survivability and Recovery"
}
},
{
"name": "Encryption",
"id": "CAT006",
"shortDescription": {
"text": "Data Security and Encryption configuration"
},
"fullDescription": {
"text": "Data Security and Encryption configuration"
}
},
{
"name": "Observability",
"id": "CAT010",
"shortDescription": {
"text": "Logging and Monitoring"
},
"fullDescription": {
"text": "Logging and Monitoring"
}
},
{
"name": "Bill Of Materials",
"id": "CAT015",
"shortDescription": {
"text": "List of resources provisioned"
},
"fullDescription": {
"text": "List of resources provisioned"
}
},
{
"name": "Access Control",
"id": "CAT001",
"shortDescription": {
"text": "Service permission and identity management"
},
"fullDescription": {
"text": "Service permission and identity management"
}
},
{
"name": "Best Practices",
"id": "CAT004",
"shortDescription": {
"text": "Metadata management"
},
"fullDescription": {
"text": "Metadata management"
}
},
{
"name": "Resource Management",
"id": "CAT011",
"shortDescription": {
"text": "Resource and privilege limit configuration"
},
"fullDescription": {
"text": "Resource and privilege limit configuration"
}
},
{
"name": "Insecure Configurations",
"id": "CAT007",
"shortDescription": {
"text": "Configurations which expose the application unnecessarily"
},
"fullDescription": {
"text": "Configurations which expose the application unnecessarily"
}
},
{
"name": "Networking and Firewall",
"id": "CAT009",
"shortDescription": {
"text": "Network port exposure and firewall configuration"
},
"fullDescription": {
"text": "Network port exposure and firewall configuration"
}
}
]
},
{
"guid": "1489b0c4-d7ce-4d31-af66-6382a01202e3",
"name": "CWE",
"fullDescription": {
"text": "The MITRE Common Weakness Enumeration"
},
"shortDescription": {
"text": "The MITRE Common Weakness Enumeration"
},
"downloadUri": "https://cwe.mitre.org/data/xml/cwec_v4.13.xml.zip",
"informationUri": "https://cwe.mitre.org/data/published/cwe_v4.13.pdf",
"isComprehensive": true,
"language": "en",
"minimumRequiredLocalizedDataSemanticVersion": "4.13",
"organization": "MITRE",
"releaseDateUtc": "2023-10-26",
"taxa": [
{
"guid": "81713b3d-740e-4d67-8003-27068b8214b4",
"id": "22",
"shortDescription": {
"text": "The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory."
},
"fullDescription": {
"text": "Many file operations are intended to take place within a restricted directory. By using special elements such as .. and / separators, attackers can escape outside of the restricted location to access files or directories that are elsewhere on the system. One of the most common special elements is the ../ sequence, which in most modern operating systems is interpreted as the parent directory of the current location. This is referred to as relative path traversal. Path traversal also covers the use of absolute pathnames such as /usr/local/bin, which may also be useful in accessing unexpected files. This is referred to as absolute path traversal. In many programming languages, the injection of a null byte (the 0 or NUL) may allow an attacker to truncate a generated filename to widen the scope of attack. For example, the product may add .txt to any pathname, thus limiting the attacker to text files, but a null injection may effectively remove this restriction."
},
"helpUri": "https://cwe.mitre.org/data/definitions/22.html"
}
]
}
]
}
]
}
Loading
Loading