apache / apache/maven-jarsigner-plugin

NPE in getCommandlineInfo() when storepass/keypass is null

Open Beginner friendly
#145 0 comments 0 reactions 0 assignees View on GitHub
bug priority:critical
Dominant language
Java
Stars
23
Forks
18
Avg merge
4h 23m
Merged PRs (30d)
2

Description

**Affected version:** HEAD

**Files:**
- `src/main/java/org/apache/maven/plugins/jarsigner/AbstractJarsignerMojo.java:376`
- `src/main/java/org/apache/maven/plugins/jarsigner/JarsignerSignMojo.java:251`

Both `getCommandlineInfo()` methods call `StringUtils.replace(commandLineInfo, this.storepass/keypass, mask)` where the password field can be null when the user hasn't configured a `storepass` or `keypass`:

```java
// AbstractJarsignerMojo.java:376
commandLineInfo = StringUtils.replace(commandLineInfo, this.storepass, "'*****'");

// JarsignerSignMojo.java:251
commandLineInfo = StringUtils.replace(commandLineInfo, this.keypass, "'*****'");
```

If `StringUtils.replace` delegates to `String.replace(CharSequence, CharSequence)` (which throws NPE on null target), this crashes whenever jarsigner returns a non-zero exit code and tries to log the command line, but the user hasn't set a password.

The fix should guard the call: only attempt replacement when the password is non-null.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with getCommandlineInfo() in src/main/java/org/apache/maven/plugins/jarsigner/AbstractJarsignerMojo.java:376 and src/main/java/org/apache/maven/plugins/jarsigner/JarsignerSignMojo.java:251. Exercise the non-zero jarsigner exit path without configuring storepass or keypass, then verify that command-line logging no longer crashes and still masks configured passwords.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.