Skip to content

fix: avoid passing empty string argument to skopeo when raw=false#380

Merged
soul2zimate merged 1 commit intoguacsec:mainfrom
soul2zimate:issue379-ImageUtils-fix
Mar 27, 2026
Merged

fix: avoid passing empty string argument to skopeo when raw=false#380
soul2zimate merged 1 commit intoguacsec:mainfrom
soul2zimate:issue379-ImageUtils-fix

Conversation

@soul2zimate
Copy link
Copy Markdown
Contributor

Replace static array construction with ArrayList to conditionally add --raw, --authfile, and --daemon-host flags, preventing an empty string from being passed as a CLI argument.

fixes #379

@qodo-code-review
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Avoid passing empty string arguments to skopeo command

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Replace static array construction with ArrayList for conditional flag addition
• Prevent empty strings from being passed as CLI arguments to skopeo
• Simplify command building logic by conditionally adding optional flags
• Improve code maintainability and reduce nested ternary complexity
Diagram
flowchart LR
  A["Static array with ternary operators"] -->|"Refactor"| B["ArrayList with conditional additions"]
  B -->|"Add flags if not empty"| C["--authfile, --daemon-host, --raw"]
  B -->|"Convert to array"| D["Clean command array"]
  D -->|"Execute"| E["skopeo inspect"]
Loading

Grey Divider

File Changes

1. src/main/java/io/github/guacsec/trustifyda/image/ImageUtils.java 🐞 Bug fix +22/-37

Refactor skopeo command building to avoid empty strings

• Replaced nested ternary operators and static array construction with ArrayList approach
• Added conditional checks to only include --authfile flag when configPath is not empty
• Added conditional checks to only include --daemon-host flag when daemonHost is not empty
• Added conditional check to only include --raw flag when raw parameter is true
• Simplified image reference formatting logic by moving it outside conditional branches

src/main/java/io/github/guacsec/trustifyda/image/ImageUtils.java


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review bot commented Mar 27, 2026

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 📐 Spec deviations (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Replace static array construction with ArrayList to conditionally add
--raw, --authfile, and --daemon-host flags, preventing an empty string
from being passed as a CLI argument.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@soul2zimate soul2zimate force-pushed the issue379-ImageUtils-fix branch from a7b7157 to 99319f9 Compare March 27, 2026 04:49
@soul2zimate soul2zimate requested a review from ruromero March 27, 2026 05:18
@soul2zimate
Copy link
Copy Markdown
Contributor Author

@ruromero Could you approve this ? Thanks

@soul2zimate soul2zimate merged commit 955d434 into guacsec:main Mar 27, 2026
30 of 39 checks passed
@soul2zimate soul2zimate deleted the issue379-ImageUtils-fix branch March 27, 2026 07:40
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.

execSkopeoInspect passes empty string as CLI argument to skopeo when raw=false

2 participants