Skip to content
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

Merged
merged 8 commits into from
Sep 25, 2023
Merged

fixed: fix Log Injection CWE-117 #604

merged 8 commits into from
Sep 25, 2023

Conversation

ds-ashanmugavel
Copy link

No description provided.

@ds-lcapellino ds-lcapellino requested a review from a team September 22, 2023 08:53
package org.eclipse.tractusx.traceability.common.model;


public class EDC {

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.

Suggested change
public class EDC {
public class SecurityUtils {


public class EDC {

public static String sanitizer(String unsanitizedInput) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static String sanitizer(String unsanitizedInput) {
public static String sanitize(String unsanitizedInput) {

Comment on lines 35 to 46
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 +
'}';
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 +
'}';
}

@Override
public String toString() {
return "EDCNotificationHeader{" +
"notificationId='" + EDC.sanitizer(notificationId) + '\'' +

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

}

@Test
public void testToString() {

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() {

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?

Comment on lines 1 to 20
/********************************************************************************
* 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
********************************************************************************/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/********************************************************************************
* 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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (String affectedItems : unSanitizedList) {
for (String affectedItem : unSanitizedList) {

return unSanitizedInput.replaceAll("\r\n|\r|\n", " ");
}

public static List<String> sanitizeList(List<String> unSanitizedList) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?

Copy link

@ds-lcapellino ds-lcapellino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ds-lcapellino ds-lcapellino merged commit 6358c0e into catenax-ng:main Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants