Skip to content

Commit

Permalink
Merge pull request #787 from taoliult/bugfix-profilename
Browse files Browse the repository at this point in the history
Fix profiles with same name beginnings being treated as one
  • Loading branch information
pshipton authored Dec 12, 2024
2 parents 4d96d60 + 7f3c7a2 commit c979e50
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,11 @@ private static void getProfileID(Properties props) {
}
String defaultMatch = null;
boolean profileExists = false;
String profilePrefix = potentialProfileID + '.';
for (Object keyObject : props.keySet()) {
if (keyObject instanceof String) {
String key = (String) keyObject;
if (key.startsWith(potentialProfileID)) {
if (key.startsWith(profilePrefix)) {
profileExists = true;
if (key.endsWith(".desc.default")) {
// Check if property is set to true.
Expand Down
5 changes: 5 additions & 0 deletions closed/test/jdk/openj9/internal/security/TestProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public TestProperties(String customprofile, String securityPropertyFile, String
@Parameters
public static List<Object[]> data() {
return Arrays.asList(new Object[][] {
// 1 - Test property - Same beginnings of the profile name without version.
{"Test-Profile-SameStartWithoutVersion",
System.getProperty("test.src") + "/property-java.security",
"(?s)(?=.*Sun)(?=.*\\bSunJCE\\b)(?=.*SunJSSE)", 0},

// 1 - Test profile - base profile misspell properties.
{"Test-Profile.Base",
System.getProperty("test.src") + "/property-java.security",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ RestrictedSecurity.Test-Profile-ConstraintChanged_3.Base.securerandom.algorithm
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.name = Test-Profile-SameStartWithoutVersion
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.default = true
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.fips = true
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.hash = SHA-256:2c893d75043da09c3dba8d8b24cb71dc1c7ceac5fb8bf362a35847418a933a06
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.hash = SHA-256:6c5546ec32c83192cf7d8bebfdf9c56049db1c957b5a69a71cb51ba8c1b23a38
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.number = Certificate #XXX
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.policy = https://csrc.nist.gov/projects/cryptographic-module-validation-program/certificate/
RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.sunsetDate = 2026-09-21
Expand Down

0 comments on commit c979e50

Please sign in to comment.