Skip to content

Commit

Permalink
CU-86b14j4e0_SRU2024_check-code-security-reports-at-GitHub-for-all-repos
Browse files Browse the repository at this point in the history
  • Loading branch information
ptorres-prowide committed Sep 18, 2024
1 parent 6dfa1c0 commit ed2f98b
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 949 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [ "main", "CU-*", "SRU*" ]
pull_request:
branches: [ "main", "SRU*" ]
branches: [ "main" ]
schedule:
- cron: "59 12 * * 2"

Expand Down
12 changes: 7 additions & 5 deletions src/main/java/com/prowidesoftware/swift/io/parser/XMLParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@
import com.prowidesoftware.swift.model.*;
import com.prowidesoftware.swift.model.field.Field;
import com.prowidesoftware.swift.utils.SafeXmlUtils;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.util.logging.Level;
import javax.xml.parsers.DocumentBuilder;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.util.logging.Level;

import javax.xml.parsers.DocumentBuilder;

/**
* This is the main parser for WIFE's XML internal representation.<br>
* The supported XML format is consider <i>internal</i> because it is an ad-hoc
Expand Down Expand Up @@ -59,7 +61,7 @@ public class XMLParser {
* @see com.prowidesoftware.swift.io.IConversionService#getMessageFromXML(java.lang.String)
*/
public SwiftMessage parse(final String xml) {
Validate.notNull(xml);
Validate.isTrue(xml != null);
try {
final DocumentBuilder db = SafeXmlUtils.documentBuilder();
final Document doc = db.parse(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,12 @@ public Integer getMessageTypeInt() {
final String number = getMessageType();
if (StringUtils.isNumeric(number)) {
try {
return Integer.parseInt(number);
return Integer.parseInt(number);
} catch (NumberFormatException e) {
log.log(Level.WARNING, "error parsing message type as number: " + e.getMessage(), e);
}
}
return null;
return null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
import com.prowidesoftware.swift.model.field.Field16R;
import com.prowidesoftware.swift.model.field.Field16S;
import com.prowidesoftware.swift.model.field.GenericField;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;

import java.io.Serializable;
import java.util.*;
import java.util.logging.Level;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;

/**
* Base class for SWIFT blocks that contain and arbitrary <b>set of fields</b> (3, 4, 5 and user blocks).<br>
Expand Down Expand Up @@ -1909,7 +1910,7 @@ public SwiftTagListBlock append(final SwiftTagListBlock... blocks) {
* @since 7.7
*/
public SwiftTagListBlock append(final Tag tag) {
Validate.notNull(tag);
Validate.isTrue(tag != null);
this.tags.add(tag);
return this;
}
Expand Down Expand Up @@ -1940,7 +1941,7 @@ public SwiftTagListBlock append(final Tag... tags) {
* @since 7.7
*/
public SwiftTagListBlock append(final Field field) {
Validate.notNull(field);
Validate.isTrue(field != null);
this.tags.add(field.asTag());
return this;
}
Expand All @@ -1953,7 +1954,7 @@ public SwiftTagListBlock append(final Field field) {
* @since 7.8
*/
public SwiftTagListBlock append(final Field... fields) {
if (fields != null && fields.length > 0) {
if (fields != null) {
for (final Field f : fields) {
append(f);
}
Expand Down
29 changes: 14 additions & 15 deletions src/main/java/com/prowidesoftware/swift/model/field/Field11T.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ public String getValueDisplay(int component, Locale locale) {
return f.format(cal.getTime());
}
}
// time: HH[mm]
java.text.DateFormat f = new java.text.SimpleDateFormat("HH:mm", notNull(locale));
java.util.Calendar cal = getComponent3AsCalendar();
if (cal != null) {
return f.format(cal.getTime());
}
return null;
// time: HH[mm]
java.text.DateFormat f = new java.text.SimpleDateFormat("HH:mm", notNull(locale));
java.util.Calendar cal = getComponent3AsCalendar();
if (cal != null) {
return f.format(cal.getTime());
}
return null;
}

/**
* Returns the field component types pattern.
Expand Down Expand Up @@ -451,7 +451,6 @@ public Field11T setComponent1(String component1) {
return this;
}


/**
* Alternative method setter for field's Type (component 1) as as Number
*
Expand Down Expand Up @@ -593,7 +592,7 @@ public Field11T setTime(java.util.Calendar component3) {
*
* @return the list of converted components (a Calendar object or null)
*/
@Override
@Override
public List<Calendar> dates() {
return DateResolver.dates(this);
}
Expand Down Expand Up @@ -686,7 +685,7 @@ public static List<Field11T> getAll(final SwiftTagListBlock block) {
* @return line content or null if not present or if line number is above the expected
* @since 7.7
*/
@Override
@Override
public String getLine(int line) {
return getLine(line, 0);
}
Expand All @@ -700,7 +699,7 @@ public String getLine(int line) {
* @return line content or null if not present or if line number is above the expected
* @since 7.7
*/
@Override
@Override
public String getLine(int line, int offset) {
Field11T cp = newInstance(this);
return getLine(cp, line, null, offset);
Expand All @@ -713,7 +712,7 @@ public String getLine(int line, int offset) {
* @return lines content or empty list if field's value is empty
* @since 7.7
*/
@Override
@Override
public List<String> getLines() {
return SwiftParseUtils.getLines(getValue());
}
Expand All @@ -726,7 +725,7 @@ public List<String> getLines() {
* @return found lines or empty list if lines are not present or the offset is invalid
* @since 7.7
*/
@Override
@Override
public List<String> getLines(int offset) {
Field11T cp = newInstance(this);
return SwiftParseUtils.getLines(getLine(cp, null, null, offset));
Expand All @@ -741,7 +740,7 @@ public List<String> getLines(int offset) {
* @return found lines or empty list if value is empty
* @since 7.7
*/
@Override
@Override
public List<String> getLinesBetween(int start, int end) {
return getLinesBetween(start, end, 0);
}
Expand All @@ -756,7 +755,7 @@ public List<String> getLinesBetween(int start, int end) {
* @return found lines or empty list if lines are not present or the offset is invalid
* @since 7.7
*/
@Override
@Override
public List<String> getLinesBetween(int start, int end, int offset) {
Field11T cp = newInstance(this);
return SwiftParseUtils.getLines(getLine(cp, start, end, offset));
Expand Down
Loading

0 comments on commit ed2f98b

Please sign in to comment.