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-08 11:34:57 +0000
commit5c3f7eec97ceda0427495881dea7168c3fe13139 (patch)
treebdd89e58e41293c85f72fef5fe80f3e0b5e74736
parentf100b1a7d1689194f08bb22e1b849c4d840dadd0 (diff)
Fix Sonar security issues in MacIpAceDataExtractor
Change-Id: I799a33f7589216c8a43c5560ed3dc58e1bf1eae1 Signed-off-by: Marek Gradzki <mgradzki@cisco.com> (cherry picked from commit e4e863d041e15af74403fbe57f813b9d07790a95)
-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};
}
}