mirror of
https://github.com/elastic/logstash.git
synced 2025-04-17 19:35:03 -04:00
Use org.logstash.common.Util to hashing by default to SHA256 (#17346)
Removes the usage fo Apache Commons Codec MessgeDigest to use internal Util class with embodies hashing methods.
This commit is contained in:
parent
10b5a84f84
commit
9c0e50faac
6 changed files with 23 additions and 11 deletions
|
@ -238,7 +238,7 @@ dependencies {
|
|||
implementation('org.reflections:reflections:0.10.2') {
|
||||
exclude group: 'com.google.guava', module: 'guava'
|
||||
}
|
||||
implementation 'commons-codec:commons-codec:1.17.0'
|
||||
implementation 'commons-codec:commons-codec:1.17.0' // transitively required by httpclient
|
||||
// Jackson version moved to versions.yml in the project root (the JrJackson version is there too)
|
||||
implementation "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
|
||||
api "com.fasterxml.jackson.core:jackson-databind:${jacksonDatabindVersion}"
|
||||
|
|
|
@ -35,6 +35,13 @@ public class Util {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hexadecimal string of UTF-8 bytes that make up the string.
|
||||
* @param base
|
||||
* the string to hash.
|
||||
* @return
|
||||
* hexadecimal string that contains the hash.
|
||||
* */
|
||||
public static String digest(String base) {
|
||||
MessageDigest digest = defaultMessageDigest();
|
||||
byte[] hash = digest.digest(base.getBytes(StandardCharsets.UTF_8));
|
||||
|
|
|
@ -19,16 +19,24 @@
|
|||
|
||||
package org.logstash.config.ir;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jruby.*;
|
||||
import org.jruby.RubyArray;
|
||||
import org.jruby.RubyClass;
|
||||
import org.jruby.RubyObject;
|
||||
import org.jruby.RubyString;
|
||||
import org.jruby.RubySymbol;
|
||||
import org.jruby.runtime.builtin.IRubyObject;
|
||||
import org.logstash.common.IncompleteSourceWithMetadataException;
|
||||
import org.logstash.common.SourceWithMetadata;
|
||||
import org.logstash.common.Util;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.logstash.RubyUtil.RUBY;
|
||||
|
@ -105,7 +113,7 @@ public final class PipelineConfig {
|
|||
|
||||
public String configHash() {
|
||||
if (configHash == null) {
|
||||
configHash = DigestUtils.sha1Hex(configString() + metadataString());
|
||||
configHash = Util.digest(configString() + metadataString());
|
||||
}
|
||||
return configHash;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package org.logstash.plugins;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.logstash.common.Util;
|
||||
import org.logstash.plugins.PluginLookup.PluginType;
|
||||
import org.logstash.plugins.aliases.AliasDocumentReplace;
|
||||
import org.logstash.plugins.aliases.AliasPlugin;
|
||||
|
@ -109,7 +109,7 @@ public class AliasRegistry {
|
|||
}
|
||||
|
||||
private String computeHashFromContent() {
|
||||
return DigestUtils.sha256Hex(yamlContents);
|
||||
return Util.digest(yamlContents);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package org.logstash.util;
|
||||
|
||||
import org.apache.commons.codec.DecoderException;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.regex.Pattern;
|
||||
|
|
|
@ -51,7 +51,7 @@ dependencies {
|
|||
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.14'
|
||||
implementation group: 'org.apache.commons', name: 'commons-compress', version: '1.26.1'
|
||||
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.14.0'
|
||||
implementation group: 'commons-codec', name: 'commons-codec', version: '1.17.0'
|
||||
implementation group: 'commons-codec', name: 'commons-codec', version: '1.17.0' // transitively required by httpclient
|
||||
|
||||
implementation group: 'commons-io', name: 'commons-io', version: '2.16.1'
|
||||
implementation "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
|
||||
|
|
Loading…
Add table
Reference in a new issue