Skip to content

Commit 6cf7e96

Browse files
authored
Merge branch 'main' into TC-3865
2 parents cec3239 + 69dd3fe commit 6cf7e96

12 files changed

Lines changed: 1341 additions & 8 deletions

File tree

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ while you build your application.
2121
- Gradle Kotlin and Groovy (gradle)
2222
- Golang (go mod)
2323
- Rust (cargo)
24-
- Python (pip) ecosystems, and base images in Dockerfile.
24+
- Python (pip, pyproject.toml) ecosystems, and base images in Dockerfile.
2525

2626
In future releases, Red Hat plans to support other package managers.
2727

@@ -108,7 +108,7 @@ according to your preferences.
108108
dependencies for Rust projects.
109109
<br >If the path is not provided, your IDE's `PATH` environment will be used to locate the executable.
110110

111-
- **Python** (`requirements.txt`) :
111+
- **Python** (`requirements.txt`, `pyproject.toml`) :
112112
<br >Set the full paths of the Python and the package installer for Python executables, which allows Exhort to locate
113113
and run the `pip3` commands to resolve dependencies for Python projects.
114114
<br >Python 2 executables `python` and `pip` can be used instead, if the `Use python 2.x` option is selected.
@@ -324,6 +324,21 @@ When modifying the grammar or lexer files, you need to regenerate the parser cla
324324
tokio = { version = "1.0", features = ["full"] } # trustify-da-ignore
325325
```
326326

327+
If you want to ignore vulnerabilities for a dependency in a `pyproject.toml` file, you must add `trustify-da-ignore` as a comment
328+
against the dependency in the manifest file.
329+
For PEP 621 format:
330+
```toml
331+
[project]
332+
dependencies = [
333+
"anyio==3.6.2", # trustify-da-ignore
334+
]
335+
```
336+
For Poetry format:
337+
```toml
338+
[tool.poetry.dependencies]
339+
anyio = "^3.6.2" # trustify-da-ignore
340+
```
341+
327342
- **Excluding developmental or test dependencies**
328343
<br >Red Hat Dependency Analytics does not analyze dependencies marked as `dev` or `test`, these dependencies are
329344
ignored.
@@ -371,6 +386,10 @@ When modifying the grammar or lexer files, you need to regenerate the parser cla
371386
You can create an alternative file to `requirements.txt`, for example, a `requirements-dev.txt` or
372387
a `requirements-test.txt` file where you can add the development or test dependencies there.
373388

389+
For `pyproject.toml`, dependencies from `[project.dependencies]` (PEP 621),
390+
`[project.optional-dependencies]`, and `[tool.poetry.dependencies]` are analyzed.
391+
Poetry group dependencies (`[tool.poetry.group.*.dependencies]`) are excluded.
392+
374393

375394
- **Excluding manifest files with patterns**
376395
<br >You can exclude specific manifest files from component analysis using configurable glob patterns. This feature allows you to avoid analyzing third-party dependencies, test files, or other manifests that are not relevant to your security analysis.

src/main/java/org/jboss/tools/intellij/componentanalysis/CAAnnotator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ public static String getPackageManager(String file) {
524524
case "pom.xml" -> "maven";
525525
case "package.json" -> "npm";
526526
case "go.mod" -> "go";
527-
case "requirements.txt" -> "python";
527+
case "requirements.txt", "pyproject.toml" -> "python";
528528
case "build.gradle", "build.gradle.kts" -> "gradle";
529529
case "Cargo.toml" -> "cargo";
530530
default -> null;

src/main/java/org/jboss/tools/intellij/componentanalysis/SAIntentionAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file
4949
|| "requirements.txt".equals(file.getName())
5050
|| "build.gradle".equals(file.getName())
5151
|| "build.gradle.kts".equals(file.getName())
52-
|| "Cargo.toml".equals(file.getName());
52+
|| "Cargo.toml".equals(file.getName())
53+
|| "pyproject.toml".equals(file.getName());
5354
}
5455

5556
@Override

src/main/java/org/jboss/tools/intellij/componentanalysis/cargo/CargoCAAnnotator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ protected String getInspectionShortName() {
7070

7171
@Override
7272
protected Map<Dependency, List<PsiElement>> getDependencies(PsiFile file) {
73+
if (!"Cargo.toml".equals(file.getName())) {
74+
return Map.of();
75+
}
76+
7377
Map<Dependency, List<PsiElement>> resultMap = new HashMap<>();
7478

7579
Set<String> commentIgnoredDeps = getIgnoredDependencies(file);
@@ -381,4 +385,4 @@ private void parseFlatDependencies(TomlTable table, Set<String> ignoredDeps, Map
381385
resultMap.computeIfAbsent(dp, k -> new LinkedList<>()).add(keyValue);
382386
}
383387
}
384-
}
388+
}

0 commit comments

Comments
 (0)