Skip to content

Avoid /bin/sh -c#7787

Open
mernst wants to merge 6 commits into
typetools:masterfrom
mernst:security-advisory-GHSA-g4jf-chwx-8gv4
Open

Avoid /bin/sh -c#7787
mernst wants to merge 6 commits into
typetools:masterfrom
mernst:security-advisory-GHSA-g4jf-chwx-8gv4

Conversation

@mernst

@mernst mernst commented Jul 2, 2026

Copy link
Copy Markdown
Member

No description provided.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@mernst, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 4 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9a22c163-3721-402d-9475-c22516949c94

📥 Commits

Reviewing files that changed from the base of the PR and between 96d3442 and d2a17a7.

📒 Files selected for processing (1)
  • framework/src/main/java/org/checkerframework/framework/stub/AnnotationFileElementTypes.java
📝 Walkthrough

Walkthrough

This PR removes shell-based subprocess execution in two places. CFGVisualizeLauncher now launches dot with ProcessBuilder and explicit arguments when producing PDFs. AnnotationFileElementTypes now prints already collected JarEntry names in stubDebug mode instead of running a /bin/sh pipeline, and removes an unused import.

Related issues: None provided
Related PRs: None provided
Suggested labels: cleanup, refactoring
Suggested reviewers: None provided

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
framework/src/main/java/org/checkerframework/framework/stub/AnnotationFileElementTypes.java (1)

897-898: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Redundant re-sorting of jar entry names.

entries is already sorted by Comparator.comparing(Object::toString) at Line 898, then jarEntryNames (built from the same entries list) is sorted again inside printSortedIndented. Since this is debug-only output on a rarely-hit path, the duplication is harmless but avoidable.

♻️ Optional simplification
-        List<String> jarEntryNames = new ArrayList<>(entries.size());
-        for (JarEntry jarEntry : entries) {
-          jarEntryNames.add(jarEntry.getName());
-        }
-        printSortedIndented(jarEntryNames);
+        List<String> jarEntryNames =
+            entries.stream().map(JarEntry::getName).collect(Collectors.toList());
+        printSortedIndented(jarEntryNames);

Also applies to: 930-935

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@framework/src/main/java/org/checkerframework/framework/stub/AnnotationFileElementTypes.java`
around lines 897 - 898, The jar entry list in AnnotationFileElementTypes is
being sorted twice: once when building entries with
Comparator.comparing(Object::toString) and again later when jarEntryNames is
passed to printSortedIndented. Remove the redundant second sort by reusing the
already-sorted entries list (and the same pattern in the later matching block),
keeping the debug-only output unchanged while avoiding duplicate work.
dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/CFGVisualizeLauncher.java (1)

328-337: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

ProcessBuilder replacement looks correct.

Equivalent behavior to the prior /bin/sh -c invocation, and avoids shell injection risk since file is passed as a discrete argument rather than interpolated into a shell command string.

One gap (pre-existing, not introduced by this diff): child.waitFor()'s exit code is never checked, so a failing dot invocation (e.g., binary missing or malformed dot file) silently produces no PDF without any error message.

♻️ Optional: surface non-zero exit codes
       ProcessBuilder pb = new ProcessBuilder("dot", "-Tpdf", file, "-o", file + ".pdf");
       Process child = pb.start();
-      child.waitFor();
+      int exitCode = child.waitFor();
+      if (exitCode != 0) {
+        System.err.println("dot exited with status " + exitCode);
+      }
     } catch (InterruptedException | IOException e) {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/CFGVisualizeLauncher.java`
around lines 328 - 337, The producePDF method starts the dot process and waits
for it, but it never checks the child exit status, so failures are silent.
Update producePDF to inspect the result of child.waitFor() after launching the
ProcessBuilder and, when the exit code is non-zero, report an error and exit
similarly to the existing exception handling; use the producePDF and child
symbols to locate the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/CFGVisualizeLauncher.java`:
- Around line 328-337: The producePDF method starts the dot process and waits
for it, but it never checks the child exit status, so failures are silent.
Update producePDF to inspect the result of child.waitFor() after launching the
ProcessBuilder and, when the exit code is non-zero, report an error and exit
similarly to the existing exception handling; use the producePDF and child
symbols to locate the change.

In
`@framework/src/main/java/org/checkerframework/framework/stub/AnnotationFileElementTypes.java`:
- Around line 897-898: The jar entry list in AnnotationFileElementTypes is being
sorted twice: once when building entries with
Comparator.comparing(Object::toString) and again later when jarEntryNames is
passed to printSortedIndented. Remove the redundant second sort by reusing the
already-sorted entries list (and the same pattern in the later matching block),
keeping the debug-only output unchanged while avoiding duplicate work.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: fcf92db5-e4d6-47a0-8e26-758bd5d176d2

📥 Commits

Reviewing files that changed from the base of the PR and between 25de9ab and 1b34e73.

📒 Files selected for processing (2)
  • dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/CFGVisualizeLauncher.java
  • framework/src/main/java/org/checkerframework/framework/stub/AnnotationFileElementTypes.java

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
framework/src/main/java/org/checkerframework/framework/stub/AnnotationFileElementTypes.java (1)

921-939: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Simplify: avoid collecting into a separate list then re-sorting.

entries is already sorted at line 899, and printSortedIndented re-sorts again at line 952. The intermediate jarEntryNames collection could be built with a stream and directly mapped, skipping the redundant sort logic in this debug-only path.

♻️ Optional simplification
-        List<String> jarEntryNames = new ArrayList<>(entries.size());
-        for (JarEntry jarEntry : entries) {
-          jarEntryNames.add(jarEntry.getName());
-        }
-        printSortedIndented(jarEntryNames);
+        printSortedIndented(
+            entries.stream().map(JarEntry::getName).collect(Collectors.toList()));

Behavior is otherwise correct and matches the flush/sleep pattern used elsewhere.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@framework/src/main/java/org/checkerframework/framework/stub/AnnotationFileElementTypes.java`
around lines 921 - 939, The debug-only jar-entry printing in
AnnotationFileElementTypes still builds a separate jarEntryNames list and then
re-sorts it via printSortedIndented even though entries is already sorted.
Simplify the block inside the stubDebug branch by mapping entries directly to
names (for example in the existing loop area) and pass that result to
printSortedIndented, or otherwise remove the redundant intermediate collection
and extra sort while keeping the existing debug output structure intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@framework/src/main/java/org/checkerframework/framework/stub/AnnotationFileElementTypes.java`:
- Around line 921-939: The debug-only jar-entry printing in
AnnotationFileElementTypes still builds a separate jarEntryNames list and then
re-sorts it via printSortedIndented even though entries is already sorted.
Simplify the block inside the stubDebug branch by mapping entries directly to
names (for example in the existing loop area) and pass that result to
printSortedIndented, or otherwise remove the redundant intermediate collection
and extra sort while keeping the existing debug output structure intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c12a4151-4a03-49cc-a090-23ea2dd502a7

📥 Commits

Reviewing files that changed from the base of the PR and between 1b34e73 and 7f7bee3.

📒 Files selected for processing (1)
  • framework/src/main/java/org/checkerframework/framework/stub/AnnotationFileElementTypes.java

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/CFGVisualizeLauncher.java (1)

328-340: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Avoid waiting on unread dot streams ProcessBuilder leaves stdout/stderr piped here, but nothing drains them before waitFor(). If dot writes enough output or hangs, this can block indefinitely. Use inheritIO() or redirect/drain the streams, and add a timeout if possible.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/CFGVisualizeLauncher.java`
around lines 328 - 340, The producePDF method launches dot and then waits
without consuming its stdout/stderr, which can deadlock the process if buffers
fill. Update producePDF to either call ProcessBuilder.inheritIO() or explicitly
redirect/drain the child streams before waitFor, and add a timeout around the
process wait if feasible. Keep the fix localized to producePDF and the
ProcessBuilder/Process child handling in CFGVisualizeLauncher.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/CFGVisualizeLauncher.java`:
- Around line 328-340: The producePDF method launches dot and then waits without
consuming its stdout/stderr, which can deadlock the process if buffers fill.
Update producePDF to either call ProcessBuilder.inheritIO() or explicitly
redirect/drain the child streams before waitFor, and add a timeout around the
process wait if feasible. Keep the fix localized to producePDF and the
ProcessBuilder/Process child handling in CFGVisualizeLauncher.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7e856a02-0afb-4a63-ba05-47820401097a

📥 Commits

Reviewing files that changed from the base of the PR and between 7f7bee3 and b00d861.

📒 Files selected for processing (1)
  • dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/CFGVisualizeLauncher.java

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@framework/src/main/java/org/checkerframework/framework/stub/AnnotationFileElementTypes.java`:
- Around line 933-934: Remove the leftover synchronous-output workaround in
AnnotationFileElementTypes, specifically the System.out.flush() and
SystemPlume.sleep(1) calls near the listing output path. Update the code so the
listing prints directly without any forced flush or pause, and keep the change
localized around the method that emits the output so the in-process behavior
remains clean.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 471612d5-9704-4e15-9003-7e983d16904f

📥 Commits

Reviewing files that changed from the base of the PR and between b00d861 and 96d3442.

📒 Files selected for processing (1)
  • framework/src/main/java/org/checkerframework/framework/stub/AnnotationFileElementTypes.java

@mernst

mernst commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Wait to merge until the next release of plume-util.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant