Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8ce1953
openssf malicious packages integration
kendrickcurtis Aug 11, 2025
74218c6
updated test to match new live CVE
kendrickcurtis Aug 11, 2025
d314bc6
revised malicious package detection to prebuild an index nightly so a…
kendrickcurtis Aug 13, 2025
b01f785
fixed build - tool wasn't scanning for package.json -- added test for…
kendrickcurtis Aug 13, 2025
ba074fc
merged main, added Dockerfile
kendrickcurtis Aug 19, 2025
c7e814b
resolved codacy warnings
kendrickcurtis Aug 19, 2025
4ee5970
fixed codacy cyclo issue
kendrickcurtis Aug 19, 2025
f84915d
fixed AI nonsense
kendrickcurtis Aug 20, 2025
e11d8a7
fixed CICD -- necessary file wasn't being copied
kendrickcurtis Aug 20, 2025
f41a50a
fixed another CICD issue
kendrickcurtis Aug 20, 2025
dfe1f8f
bugfix in tool.go to live with nil PURLs and fixed absent line number…
kendrickcurtis Aug 20, 2025
45da0ab
stopped copying unnecessary files
kendrickcurtis Aug 20, 2025
d2d5356
fixed test data
kendrickcurtis Aug 21, 2025
a4efa1c
test fixes
kendrickcurtis Aug 21, 2025
83b035a
ignored codacy config
kendrickcurtis Sep 9, 2025
4082165
review comments tackled
kendrickcurtis Sep 29, 2025
649f440
fixed stupid ai shit - npm ref in gradle file
kendrickcurtis Sep 29, 2025
76cf210
fixed missing vuln
kendrickcurtis Oct 3, 2025
1385e2b
Delete .codacy/cli.sh
kendrickcurtis Nov 25, 2025
1234196
Delete .codacy/codacy.yaml
kendrickcurtis Nov 25, 2025
438d8ef
clean: Assorted cleanup after rebase
afsmeira Nov 26, 2025
0401b2a
clean: Improve build process for OpenSSF malicious packages index
afsmeira Nov 26, 2025
ef99b5d
clean: Simplify and correct malicious packages scanner implementation
afsmeira Nov 26, 2025
76f19a4
clean: Ensure proper dependency injection for testable code
afsmeira Nov 26, 2025
d6f2a33
clean: Address codacy comments
afsmeira Nov 26, 2025
d6fb292
tests: Add unit tests and fix faulty implementations
afsmeira Nov 27, 2025
df03b28
ci: Serialize steps to avoid problems when saving to workspace
afsmeira Nov 27, 2025
b96b28d
tests: Fix integration tests
afsmeira Nov 27, 2025
dd6bd7c
clean: Log when failing to open file when building index
afsmeira Nov 27, 2025
852dd65
clean: Address AI review comments
afsmeira Nov 27, 2025
194cdf1
feat: Support the `last_affected` field in range events
afsmeira Nov 27, 2025
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
21 changes: 19 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ references:
mkdir cache
./trivy --cache-dir ./cache image --download-db-only

build_openssf_malicious_package_index: &build_openssf_malicious_package_index
persist_to_workspace: true
cmd: |
mkdir openssf-malicious-packages
curl -sfL https://api.github.com/repos/ossf/malicious-packages/tarball/main | tar -xz --strip-components=1 -C openssf-malicious-packages
python3 scripts/build_openssf_index.py

build_and_publish_docker: &build_and_publish_docker
persist_to_workspace: true
cmd: |
Expand All @@ -36,11 +43,16 @@ workflows:
name: install_trivy_and_download_dbs
requires:
- generate_and_test
- codacy/shell:
<<: *build_openssf_malicious_package_index
name: build_openssf_malicious_package_index
requires:
- install_trivy_and_download_dbs
- codacy/shell:
<<: *build_and_publish_docker
name: publish_docker_local
requires:
- install_trivy_and_download_dbs
- build_openssf_malicious_package_index
- codacy_plugins_test/run:
name: plugins_test
run_multiple_tests: true
Expand Down Expand Up @@ -84,11 +96,16 @@ workflows:
name: install_trivy_and_download_dbs
requires:
- generate_and_test
- codacy/shell:
<<: *build_openssf_malicious_package_index
name: build_openssf_malicious_package_index
requires:
- install_trivy_and_download_dbs
- codacy/shell:
<<: *build_and_publish_docker
name: publish_docker_local
requires:
- install_trivy_and_download_dbs
- build_openssf_malicious_package_index
- codacy/publish_docker:
name: publish_dockerhub
context: CodacyDocker
Expand Down
14 changes: 11 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,21 @@ project
target
bin
cache
openssf-malicious-packages
*.gen.go
.codacyrc
trivy


#Ignore vscode AI rules
# Ignore vscode AI rules
.github/copilot-instructions.md

#Ignore cursor AI rules
.cursor/rules/codacy.mdc
# Ignore cursor AI rules
.cursor/rules/codacy.mdc

# Ignore codacy stuff
.codacy/cli.sh
.codacy/codacy.yaml

# Ignore patterns.json
docs/patterns.json
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.25-alpine as builder
FROM golang:1.25-alpine AS builder

ARG TRIVY_VERSION=dev
ENV TRIVY_VERSION=$TRIVY_VERSION
Expand Down Expand Up @@ -31,5 +31,6 @@ RUN adduser -u 2004 -D docker
COPY --from=builder --chown=docker:docker /src/bin /dist/bin
COPY --from=builder --chown=docker:docker /src/docs /docs
COPY --chown=docker:docker cache/ /dist/cache/codacy-trivy
COPY --chown=docker:docker openssf-malicious-packages/openssf-malicious-packages-index.json.gz /dist/cache/codacy-trivy/openssf-malicious-packages-index.json.gz

CMD [ "/dist/bin/codacy-trivy" ]
10 changes: 8 additions & 2 deletions cmd/tool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ import (

codacy "github.com/codacy/codacy-engine-golang-seed/v6"
"github.com/codacy/codacy-trivy/internal/tool"
"github.com/sirupsen/logrus"
)

func main() {
codacyTrivy := tool.New()
retCode := codacy.StartTool(&codacyTrivy)
codacyTrivy, err := tool.New(tool.MaliciousPackagesIndexPath)
if err != nil {
logrus.Errorf("Failed to create tool execution: %s", err.Error())
os.Exit(-1)
}

retCode := codacy.StartTool(codacyTrivy)

os.Exit(retCode)
}
2 changes: 2 additions & 0 deletions docs/description/malicious_packages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## Malicious packages detection
Detects malicious packages identified in the OpenSSF Malicious Packages database, including typosquatting attacks, dependency confusion, and packages with malicious payloads.
1 change: 1 addition & 0 deletions docs/multiple-tests/all-patterns/patterns.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<module name="vulnerability_high" />
<module name="vulnerability_medium" />
<module name="vulnerability_minor" />
<module name="malicious_packages" />
</module>
10 changes: 9 additions & 1 deletion docs/multiple-tests/all-patterns/results.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,12 @@
severity="warning"
/>
</file>
</checkstyle>
<file name="javascript/package-lock.json">
<error
source="malicious_packages"
line="11"
message="Malicious code in sdge-it-tdg-dynamicloadprofiles (npm) - [email protected]"
severity="error"
/>
</file>
</checkstyle>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
org.apache.logging.log4j:log4j-core:2.17.0
org.apache.dolphinscheduler:dolphinscheduler-task-api:3.2.1
org.apache.seatunnel:seatunnel:1.0.0
org.apache.cxf:cxf-rt-transports-http:4.0.0
org.apache.cxf:cxf-rt-transports-http:4.0.0
npm:commitlint-pm2-proxima-dotenv-safe:1.0.0

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions docs/multiple-tests/pattern-malicious-packages/patterns.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<module name="root">
<module name="malicious_packages" />
</module>
11 changes: 11 additions & 0 deletions docs/multiple-tests/pattern-malicious-packages/results.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="1.5">
<file name="javascript/package-lock.json">
<error
source="malicious_packages"
line="11"
message="Malicious code in sdge-it-tdg-dynamicloadprofiles (npm) - [email protected]"
severity="error"
/>
</file>
</checkstyle>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
<module name="root">
<module name="vulnerability_critical" />
</module>

6 changes: 0 additions & 6 deletions docs/multiple-tests/pattern-vulnerability-high/results.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,6 @@
message="Insecure dependency golang/[email protected] (CVE-2025-58187: Due to the design of the name constraint checking algorithm, the proce ...) (update to 1.24.9)"
severity="high"
/>
<error
source="vulnerability_high"
line="5"
message="Insecure dependency golang/[email protected] (CVE-2025-58188: Validating certificate chains which contain DSA public keys can cause ...) (update to 1.24.8)"
severity="high"
/>
<error
source="vulnerability_high"
line="5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@
message="Insecure dependency golang/[email protected] (CVE-2025-61724: net/textproto: Excessive CPU consumption in Reader.ReadResponse in net/textproto) (update to 1.24.8)"
severity="warning"
/>
<error
source="vulnerability_medium"
line="3"
message="Insecure dependency golang/[email protected] (CVE-2025-58188: crypto/x509: golang: Panic when validating certificates with DSA public keys in crypto/x509) (update to 1.24.8)"
severity="warning"
/>
</file>

<file name="gradle/gradle.lockfile">
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/google/go-cmp v0.7.0
github.com/package-url/packageurl-go v0.1.3
github.com/samber/lo v1.52.0
github.com/sirupsen/logrus v1.9.3 // Logrus is the logging library used in codacy-engine-golang-seed
github.com/stretchr/testify v1.11.1
go.uber.org/mock v0.6.0
golang.org/x/mod v0.30.0
Expand Down Expand Up @@ -316,7 +317,6 @@ require (
github.com/sigstore/rekor v1.4.2 // indirect
github.com/sigstore/sigstore v1.9.5 // indirect
github.com/sigstore/timestamp-authority v1.2.2 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/skeema/knownhosts v1.3.1 // indirect
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
github.com/spdx/tools-golang v0.5.5 // indirect
Expand Down
10 changes: 10 additions & 0 deletions internal/docgen/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,15 @@ func trivyRules() Rules {
ScanType: "SCA",
Enabled: true,
},
{
ID: "malicious_packages",
Title: "Malicious packages detection",
Description: "Detects malicious packages identified in the OpenSSF Malicious Packages database, including typosquatting attacks, dependency confusion, and packages with malicious payloads.",
Level: "Error",
Category: "Security",
SubCategory: "InsecureModulesLibraries",
ScanType: "SCA",
Enabled: true,
},
}
}
2 changes: 1 addition & 1 deletion internal/tool/doc.go
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// The tool package has the implementation of `codacy-trivy`.
// Package tool implements the Codacy Trivy tool.
package tool
Loading