Skip to content

Conversation

@wangweij
Copy link
Contributor

@wangweij wangweij commented Jun 7, 2024

There are two is one changes:

  1. In jarsigner -verify, check a .SF file contains un-existing entries and print them out as
Warning: nonexistent signed entries detected: [a]

2. In JarSigner::sign0, when creating a new .SF file, only include signed file entries.

Update: Even when the JAR file is re-signed, the hash entry for the missing file will be in the new .SF file. There is no way to tell if this is for a file entry or a user-defined entry.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change requires CSR request JDK-8334261 to be approved
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issues

  • JDK-8309841: Jarsigner should print a warning if an entry is removed (Enhancement - P3)
  • JDK-8334261: Jarsigner should print a warning if an entry is removed (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/19599/head:pull/19599
$ git checkout pull/19599

Update a local copy of the PR:
$ git checkout pull/19599
$ git pull https://git.openjdk.org/jdk.git pull/19599/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19599

View PR using the GUI difftool:
$ git pr show -t 19599

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/19599.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 7, 2024

👋 Welcome back weijun! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jun 7, 2024

@wangweij This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8309841: Jarsigner should print a warning if an entry is removed

Reviewed-by: mullan, hchao

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 287 new commits pushed to the master branch:

  • dc0ce1b: 8341336: Fix -Wzero-as-null-pointer-constant warnings in PRODUCT-only code
  • c43202b: 8341037: Use standard layouts in DefaultFrameIconTest.java and MenuCrash.java
  • 76283dd: 8341246: Test com/sun/tools/attach/PermissionTest.java fails access denied after JDK-8327114
  • 0bdfe88: 8328313: Archived module graph should allow identical --module-path to be specified during dump time and run time
  • 9fc1c68: 8339850: Restore the interrupt status in FileSystemPreferences.lockFile()
  • 5063494: 8340785: Update description of PassFailJFrame and samples
  • 85f0442: 8317116: Provide layouts for multiple test UI in PassFailJFrame
  • 49501fe: 8341412: Various test failures after JDK-8334305
  • 8838048: 8324259: Classes used by CDS at runtime should be archived
  • 5e98007: 8307532: Implement LM_LIGHTWEIGHT for Zero
  • ... and 277 more: https://git.openjdk.org/jdk/compare/1b17e0b133cab44029333c832bd046b338ede581...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Jun 7, 2024

@wangweij The following labels will be automatically applied to this pull request:

  • core-libs
  • security

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added security security-dev@openjdk.org core-libs core-libs-dev@openjdk.org labels Jun 7, 2024
@wangweij
Copy link
Contributor Author

wangweij commented Jun 7, 2024

/label remove core-libs

@openjdk openjdk bot removed the core-libs core-libs-dev@openjdk.org label Jun 7, 2024
@openjdk
Copy link

openjdk bot commented Jun 7, 2024

@wangweij
The core-libs label was successfully removed.

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Jun 13, 2024
@bridgekeeper
Copy link

bridgekeeper bot commented Aug 2, 2024

@wangweij This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@wangweij
Copy link
Contributor Author

Ask again for review.

@wangweij wangweij marked this pull request as ready for review September 12, 2024 13:30
@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 12, 2024
@mlbridge
Copy link

mlbridge bot commented Sep 12, 2024

@driverkt
Copy link
Member

You can mark my above comments as resolved.

@haimaychao
Copy link
Contributor

CSR looks good to me. Clarifying that non-file entries in MANIFEST.MF could cause false positive is useful in the CSR.


{"history.with.ts", "- Signed by \"%1$s\"\n Digest algorithm: %2$s\n Signature algorithm: %3$s, %4$s\n Timestamped by \"%6$s\" on %5$tc\n Timestamp digest algorithm: %7$s\n Timestamp signature algorithm: %8$s, %9$s"},
{"history.without.ts", "- Signed by \"%1$s\"\n Digest algorithm: %2$s\n Signature algorithm: %3$s, %4$s"},
{"history.nonexistent.entries", " Warning: nonexistent signed entries: "},
Copy link
Contributor

Choose a reason for hiding this comment

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

Inline with existing warning message, can it be "WARNING: Nonexistent signed entries: "

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This warning is a part of a block on signer info and I'd like the word does not stand out too much. For example, the test shows:

- Signed by "CN=x"
    Digest algorithm: SHA-384
    Signature algorithm: Ed25519, 255-bit key
    Warning: nonexistent signed entries: [a]

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks

@haimaychao
Copy link
Contributor

Suggest to add testcases to remove more than one entry or file ending with "*" in RemovedFiles.

@haimaychao
Copy link
Contributor

Do you think it may be useful to have a testcase that falsely reports the missing entry?

@wangweij
Copy link
Contributor Author

wangweij commented Sep 12, 2024

Suggest to add testcases to remove more than one entry or file ending with "*" in RemovedFiles.

This can be a test to the JarUtils method itself. I can add one.

Do you think it may be useful to have a testcase that falsely reports the missing entry?

I'll add one.

@haimaychao
Copy link
Contributor

Thanks for adding more testcases for this PR. Changes look good.

{"key.bit.disabled", "%d-bit key (disabled)"},
{"key.bit.eccurve.disabled", "%1$d-bit %2$s key (disabled)"},
{"unknown.size", "unknown size"},
{"nonexistent.entries.found", "Nonexistent signed entries detected. See details in -verbose output."},
Copy link
Member

Choose a reason for hiding this comment

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

For the second sentence, in other warning messages, we say "Re-run jarsigner with the -verbose option for more details." Perhaps we should be consistent?

Copy link
Member

Choose a reason for hiding this comment

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

Actually, I see the output will also contain the message "Re-run with the -verbose and -certs options for more details." so I take back my comment above.

Copy link
Member

Choose a reason for hiding this comment

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

For this summary message, I suggest we be a bit more descriptive like in other messages:

"This jar contains signed entries for files that do not exist. See the -verbose output for more details."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. Thanks.

// Note: b* covers everything starting with b, even bx/x
JarUtils.deleteEntries(Path.of("a.jar"), "b*");
Asserts.assertEquals(Set.of("c"), content("a.jar"));
}
Copy link
Member

Choose a reason for hiding this comment

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

You could also add a test where the pattern doesn't match, and a test where there is more than one pattern, and the matching pattern is not the first one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed csr Pull request needs approved CSR before integration labels Oct 1, 2024
@wangweij wangweij changed the title 8309841: Jarsigner should print a warning if an entry is removed 8337496: Improve jarsigner utility handling of missing content Oct 2, 2024
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Oct 2, 2024
@wangweij wangweij changed the title 8337496: Improve jarsigner utility handling of missing content 8309841: Jarsigner should print a warning if an entry is removed Oct 2, 2024
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 2, 2024
@wangweij
Copy link
Contributor Author

wangweij commented Oct 2, 2024

/integrate

@openjdk
Copy link

openjdk bot commented Oct 2, 2024

Going to push as commit bdfb41f.
Since your change was applied there have been 288 commits pushed to the master branch:

  • 57c1db5: 8332697: ubsan: shenandoahSimpleBitMap.inline.hpp:68:23: runtime error: signed integer overflow: -9223372036854775808 - 1 cannot be represented in type 'long int'
  • dc0ce1b: 8341336: Fix -Wzero-as-null-pointer-constant warnings in PRODUCT-only code
  • c43202b: 8341037: Use standard layouts in DefaultFrameIconTest.java and MenuCrash.java
  • 76283dd: 8341246: Test com/sun/tools/attach/PermissionTest.java fails access denied after JDK-8327114
  • 0bdfe88: 8328313: Archived module graph should allow identical --module-path to be specified during dump time and run time
  • 9fc1c68: 8339850: Restore the interrupt status in FileSystemPreferences.lockFile()
  • 5063494: 8340785: Update description of PassFailJFrame and samples
  • 85f0442: 8317116: Provide layouts for multiple test UI in PassFailJFrame
  • 49501fe: 8341412: Various test failures after JDK-8334305
  • 8838048: 8324259: Classes used by CDS at runtime should be archived
  • ... and 278 more: https://git.openjdk.org/jdk/compare/1b17e0b133cab44029333c832bd046b338ede581...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Oct 2, 2024
@openjdk openjdk bot closed this Oct 2, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Oct 2, 2024
@openjdk
Copy link

openjdk bot commented Oct 2, 2024

@wangweij Pushed as commit bdfb41f.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@wangweij wangweij deleted the 8309841 branch October 4, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integrated Pull request has been integrated security security-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

5 participants