summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-09-07 12:32:46 +0200
committerMarek Gradzki <mgradzki@cisco.com>2017-09-07 12:32:46 +0200
commite4e863d041e15af74403fbe57f813b9d07790a95 (patch)
treede6cfcca26a1cf5924ebde0dfc2b718f4dba4e8a
parent7e90b6c5f8a605470dd388bf3c31d9f5beb2724c (diff)
Fix Sonar security issues in MacIpAceDataExtractor
Change-Id: I799a33f7589216c8a43c5560ed3dc58e1bf1eae1 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
-rw-r--r--acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/util/ace/extractor/MacIpAceDataExtractor.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/util/ace/extractor/MacIpAceDataExtractor.java b/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/util/ace/extractor/MacIpAceDataExtractor.java
index fd1a28b46..ddb41ee3c 100644
--- a/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/util/ace/extractor/MacIpAceDataExtractor.java
+++ b/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/util/ace/extractor/MacIpAceDataExtractor.java
@@ -41,11 +41,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.
public interface MacIpAceDataExtractor extends AddressExtractor, MacTranslator {
- String DEFAULT_MAC = "00:00:00:00:00:00";
- String DEFAULT_MAC_MASK = "00:00:00:00:00:00";
- byte[] DEFAULT_MAC_BYTES = {0, 0, 0, 0, 0, 0};
- byte[] DEFAULT_MAC_MASK_BYTES = {0, 0, 0, 0, 0, 0};
-
default VppMacipAce fromMacIpAce(@Nonnull final Ace ace) {
return Optional.ofNullable(ace.getMatches())
.map(Matches::getAceType)
@@ -65,14 +60,14 @@ public interface MacIpAceDataExtractor extends AddressExtractor, MacTranslator {
return macToByteArray(Optional.ofNullable(ace.getVppMacipAceNodes())
.map(VppMacipAceEthHeaderFields::getSourceMacAddress)
.map(MacAddress::getValue)
- .orElse(DEFAULT_MAC));
+ .orElse(Impl.DEFAULT_MAC));
}
default byte[] sourceMacMaskAsBytes(@Nonnull final VppMacipAce ace) {
return macToByteArray(Optional.ofNullable(ace.getVppMacipAceNodes())
.map(VppMacipAceEthHeaderFields::getSourceMacAddressMask)
.map(MacAddress::getValue)
- .orElse(DEFAULT_MAC_MASK));
+ .orElse(Impl.DEFAULT_MAC_MASK));
}
default byte[] ipv4Address(@Nonnull final VppMacipAce ace) {
@@ -152,12 +147,19 @@ public interface MacIpAceDataExtractor extends AddressExtractor, MacTranslator {
default MacAddress sourceMac(@Nonnull final MacipAclRule rule) {
return new MacAddress(byteArrayToMacSeparated(rule.srcMac != null
? rule.srcMac
- : DEFAULT_MAC_BYTES));
+ : Impl.DEFAULT_MAC_BYTES));
}
default MacAddress sourceMacMask(@Nonnull final MacipAclRule rule) {
return new MacAddress(byteArrayToMacSeparated(rule.srcMacMask != null
? rule.srcMacMask
- : DEFAULT_MAC_MASK_BYTES));
+ : Impl.DEFAULT_MAC_MASK_BYTES));
+ }
+
+ final class Impl {
+ private static final String DEFAULT_MAC = "00:00:00:00:00:00";
+ private static final String DEFAULT_MAC_MASK = "00:00:00:00:00:00";
+ private static final byte[] DEFAULT_MAC_BYTES = {0, 0, 0, 0, 0, 0};
+ private static final byte[] DEFAULT_MAC_MASK_BYTES = {0, 0, 0, 0, 0, 0};
}
}