mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Valery Kharseko
8 hours ago 65111c6f7556527decee160246183cf1b865587e
Fix type-mismatch, index-out-of-bounds and boxed-equality CodeQL alerts (#782)
5 files modified
56 ■■■■ changed files
opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/GenerateMessageFileMojo.java 29 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/core/EntryCacheConfigManager.java 10 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/extensions/BCrypt.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/messages/org/opends/messages/protocol.properties 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/extensions/BCryptTest.java 13 ●●●●● patch | view | raw | blame | history
opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/GenerateMessageFileMojo.java
@@ -33,6 +33,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.Set;
import java.util.TreeMap;
@@ -145,16 +146,26 @@
        }
        /**
         * Compare message entries by unique identifier.
         * Compare message entries by ordinal, then by unique identifier.
         * <p>
         * Entries are held in a {@code TreeSet}, so this must be a total order:
         * returning 0 for entries that are not the same message drops them from
         * the log reference. Entries without an ordinal sort first, as they do
         * in {@link MessagePropertyKey#compareTo(MessagePropertyKey)}.
         *
         * @return See {@link java.lang.Comparable#compareTo(Object)}.
         */
        @Override
        public int compareTo(MessageRefEntry mre) {
            if (this.ordinal != null && mre.ordinal != null) {
                return this.ordinal.compareTo(mre.ordinal);
            if (Objects.equals(ordinal, mre.ordinal)) {
                return xmlId.compareTo(mre.xmlId);
            } else if (ordinal == null) {
                return -1;
            } else if (mre.ordinal == null) {
                return 1;
            } else {
                return ordinal.compareTo(mre.ordinal);
            }
            return 0;
        }
    }
@@ -245,12 +256,14 @@
        @Override
        public int compareTo(MessagePropertyKey k) {
            if (ordinal == k.ordinal) {
            if (Objects.equals(ordinal, k.ordinal)) {
                return description.compareTo(k.description);
            } else if (ordinal != null && k.ordinal != null) {
                return ordinal.compareTo(k.ordinal);
            } else if (ordinal == null) {
                return -1;
            } else if (k.ordinal == null) {
                return 1;
            } else {
                return 0;
                return ordinal.compareTo(k.ordinal);
            }
        }
    }
opendj-server-legacy/src/main/java/org/opends/server/core/EntryCacheConfigManager.java
@@ -13,6 +13,7 @@
 *
 * Copyright 2006-2008 Sun Microsystems, Inc.
 * Portions Copyright 2013-2016 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.opends.server.core;
@@ -20,7 +21,6 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.util.Utils;
import org.forgerock.opendj.config.ClassPropertyDefinition;
import org.forgerock.opendj.config.server.ConfigurationAddListener;
@@ -207,9 +207,9 @@
    if (!cacheOrderMap.isEmpty() && !cacheNameToLevelMap.isEmpty())
    {
      final ByteString normDN = configuration.dn().toNormalizedByteString();
      if (cacheNameToLevelMap.containsKey(normDN)) {
        int currentCacheLevel = cacheNameToLevelMap.get(normDN);
      final DN dn = configuration.dn();
      if (cacheNameToLevelMap.containsKey(dn)) {
        int currentCacheLevel = cacheNameToLevelMap.get(dn);
        // Check if there any existing cache at the same level.
        if (currentCacheLevel != configuration.getCacheLevel() &&
@@ -411,7 +411,7 @@
      }
      entryCache.finalizeEntryCache();
      cacheOrderMap.remove(configuration.getCacheLevel());
      cacheNameToLevelMap.remove(configuration.dn().toNormalizedByteString());
      cacheNameToLevelMap.remove(configuration.dn());
      // Push any changes made to the cache order map.
      setCacheOrder(cacheOrderMap);
opendj-server-legacy/src/main/java/org/opends/server/extensions/BCrypt.java
@@ -437,7 +437,7 @@
   * @return  the decoded value of x
   */
  private static byte char64(char x) {
    if (x < 0 || x > index_64.length) {
    if (x >= index_64.length) {
      return -1;
    }
    return index_64[x];
opendj-server-legacy/src/messages/org/opends/messages/protocol.properties
@@ -860,5 +860,5 @@
ERR_SNMP_CONNHANDLER_OPENDMK_JARFILES_NOT_OPERATIONAL_1507=The required \
 classes could not be loaded using jar file '%s'. Verify that the jar file \
 is not corrupted
ERR_HTTP_ERROR_WHILE_PROCESSING_REQUEST_1508=An error occurred while processing the request \
ERR_HTTP_ERROR_WHILE_PROCESSING_REQUEST_1539=An error occurred while processing the request \
 %s: %s
opendj-server-legacy/src/test/java/org/opends/server/extensions/BCryptTest.java
@@ -24,6 +24,7 @@
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 * Portions Copyright 2026 3A Systems, LLC.
 *
 */
@@ -198,6 +199,18 @@
    }
    /**
     * A stored password whose salt holds a character beyond the base64 decoding table
     * must fail with the IllegalArgumentException that
     * BcryptPasswordStorageScheme.passwordMatches() catches, and not with an
     * ArrayIndexOutOfBoundsException escaping into bind processing.
     */
    @Test(expectedExceptions = IllegalArgumentException.class)
    public void checkPwRejectsSaltCharBeyondDecodingTable() {
        // U+0080 is the first character past the end of the 128 entry index_64 table.
        BCrypt.checkpw("secret", "$2a$10$" + ((char) 0x80) + "aaaaaaaaaaaaaaaaaaaaa");
    }
    /**
     *     Test for correct hashing of non-US-ASCII passwords.
     */
    @Test