-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed: fix Log Injection CWE-117 #604
Conversation
package org.eclipse.tractusx.traceability.common.model; | ||
|
||
|
||
public class EDC { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EDC means Eclipse Dataspace Connector. This class should have a security related name.
public class EDC { | |
public class SecurityUtils { |
|
||
public class EDC { | ||
|
||
public static String sanitizer(String unsanitizedInput) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static String sanitizer(String unsanitizedInput) { | |
public static String sanitize(String unsanitizedInput) { |
public String toString() { | ||
String cleanInformation = EDC.sanitizer(information); | ||
List<String> cleanListOfAffectedItems = new ArrayList<>(); | ||
for (String AffectedItems : listOfAffectedItems) { | ||
String cleanAffectedItem = EDC.sanitizer(AffectedItems); | ||
cleanListOfAffectedItems.add(cleanAffectedItem); | ||
} | ||
return "EDCNotificationContent{" + | ||
"information='" + cleanInformation + '\'' + | ||
", listOfAffectedItems=" + cleanListOfAffectedItems + | ||
'}'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public String toString() { | |
String cleanInformation = EDC.sanitizer(information); | |
List<String> cleanListOfAffectedItems = new ArrayList<>(); | |
for (String AffectedItems : listOfAffectedItems) { | |
String cleanAffectedItem = EDC.sanitizer(AffectedItems); | |
cleanListOfAffectedItems.add(cleanAffectedItem); | |
} | |
return "EDCNotificationContent{" + | |
"information='" + cleanInformation + '\'' + | |
", listOfAffectedItems=" + cleanListOfAffectedItems + | |
'}'; | |
} | |
public String toString() { | |
List<String> cleanListOfAffectedItems = new ArrayList<>(); | |
for (String affectedItem : listOfAffectedItems) { | |
String cleanAffectedItem = EDC.sanitizer(AffectedItems); | |
cleanListOfAffectedItems.add(cleanAffectedItem); | |
} | |
return "EDCNotificationContent{" + | |
"information='" + EDC.sanitizer(information) + '\'' + | |
", listOfAffectedItems=" + cleanListOfAffectedItems + | |
'}'; | |
} |
...actusx/traceability/qualitynotification/infrastructure/edc/model/EDCNotificationContent.java
Outdated
Show resolved
Hide resolved
@Override | ||
public String toString() { | ||
return "EDCNotificationHeader{" + | ||
"notificationId='" + EDC.sanitizer(notificationId) + '\'' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the class as static import so the class name is not visible in each line
...ava/org/eclipse/tractusx/traceability/infrastructure/edc/model/EdcNotificationModelTest.java
Show resolved
Hide resolved
...ava/org/eclipse/tractusx/traceability/infrastructure/edc/model/EdcNotificationModelTest.java
Show resolved
Hide resolved
...ava/org/eclipse/tractusx/traceability/infrastructure/edc/model/EdcNotificationModelTest.java
Show resolved
Hide resolved
} | ||
|
||
@Test | ||
public void testToString() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please insert same //GIVEN //WHEN //THEN pattern as above.
public class EdcNotificationModelTest { | ||
|
||
@Test | ||
public void testToStringWithRegex() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the regex in this method?
/******************************************************************************** | ||
* Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* Copyright (c) 2022, 2023 ZF Friedrichshafen AG | ||
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/******************************************************************************** | |
* Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | |
* Copyright (c) 2022, 2023 ZF Friedrichshafen AG | |
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation | |
* | |
* See the NOTICE file(s) distributed with this work for additional | |
* information regarding copyright ownership. | |
* | |
* This program and the accompanying materials are made available under the | |
* terms of the Apache License, Version 2.0 which is available at | |
* https://www.apache.org/licenses/LICENSE-2.0. | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |
* License for the specific language governing permissions and limitations | |
* under the License. | |
* | |
* SPDX-License-Identifier: Apache-2.0 | |
********************************************************************************/ | |
/******************************************************************************** | |
* Copyright (c) 2023 Contributors to the Eclipse Foundation | |
* | |
* See the NOTICE file(s) distributed with this work for additional | |
* information regarding copyright ownership. | |
* | |
* This program and the accompanying materials are made available under the | |
* terms of the Apache License, Version 2.0 which is available at | |
* https://www.apache.org/licenses/LICENSE-2.0. | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |
* License for the specific language governing permissions and limitations | |
* under the License. | |
* | |
* SPDX-License-Identifier: Apache-2.0 | |
********************************************************************************/ |
Please use this as a copyright header.
|
||
public static List<String> sanitizeList(List<String> unSanitizedList) { | ||
List<String> cleanListOfAffectedItems = new ArrayList<>(); | ||
for (String affectedItems : unSanitizedList) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (String affectedItems : unSanitizedList) { | |
for (String affectedItem : unSanitizedList) { |
return unSanitizedInput.replaceAll("\r\n|\r|\n", " "); | ||
} | ||
|
||
public static List<String> sanitizeList(List<String> unSanitizedList) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static List<String> sanitizeList(List<String> unSanitizedList) { | |
public static List<String> sanitizeList(List<String> unsanitizedList) { |
return unSanitizedInput.replaceAll("\r\n|\r|\n", " "); | ||
} | ||
|
||
public static List<String> sanitizeList(List<String> unSanitizedList) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static List<String> sanitizeList(List<String> unSanitizedList) { | |
public static List<String> sanitize(List<String> unSanitizedList) { |
I think it would be better to just overload the method with new parameters instead of renaming it. What is your take on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.