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

Fix couple Security Hotspots #143

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@ public NihmsReceiveMailService(PassClient passClient,
}

private final List<Pattern> depositFailurePatterns = List.of(
Pattern.compile("package id=(.*) failed because.*", Pattern.CASE_INSENSITIVE),
Pattern.compile("package id=(.*) was not submitted.*", Pattern.CASE_INSENSITIVE),
Pattern.compile("package id=(.*) is corrupt.*", Pattern.CASE_INSENSITIVE),
Pattern.compile("package id=(.*) was already used for Manuscript.*submission not created.*",
Pattern.compile("package id=(\\S{1,75}) failed because.*", Pattern.CASE_INSENSITIVE),
Pattern.compile("package id=(\\S{1,75}) was not submitted.*", Pattern.CASE_INSENSITIVE),
Pattern.compile("package id=(\\S{1,75}) is corrupt.*", Pattern.CASE_INSENSITIVE),
Pattern.compile("package id=(\\S{1,75}) was already used for Manuscript.*submission not created.*",
Pattern.CASE_INSENSITIVE),
Pattern.compile("package id=(.*) for Manuscript.*submitted with the following problem.*",
Pattern.compile("package id=(\\S{1,75}) for Manuscript.*submitted with the following problem.*",
Pattern.CASE_INSENSITIVE),
Pattern.compile("package id=(.*) contains unrecognized.*", Pattern.CASE_INSENSITIVE)
Pattern.compile("package id=(\\S{1,75}) contains unrecognized.*", Pattern.CASE_INSENSITIVE)
);

private final Pattern depositSuccessPattern =
Pattern.compile("package id=(.*) for Manuscript ID (.*) was submitted successfully.*",
Pattern.compile("package id=(\\S{1,75}) for Manuscript ID (\\S{1,25}) was submitted successfully.*",
Pattern.CASE_INSENSITIVE);

public void handleReceivedMail(MimeMessage receivedMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

Expand All @@ -34,6 +36,8 @@
@Component
public class NihmsHarvesterCLIRunner implements CommandLineRunner {

private static final Logger LOG = LoggerFactory.getLogger(NihmsHarvesterCLIRunner.class);

/**
* Request for help/usage documentation
*/
Expand Down Expand Up @@ -96,7 +100,6 @@ public void run(String... args) {
/* Handle general options such as help, version */
if (this.help) {
parser.printUsage(System.err);
System.err.println();
System.exit(0);
}

Expand All @@ -121,16 +124,10 @@ public void run(String... args) {
nihmsHarvester.harvest(statusesToProcess, harvestPeriodMonths);

} catch (CmdLineException e) {
/**
* This is an error in command line args, just print out usage data
* and description of the error.
*/
System.err.println(e.getMessage());
parser.printUsage(System.err);
System.exit(1);
} catch (Exception e) {
e.printStackTrace();
System.err.println(e.getMessage());
LOG.error("Error running Nihms Harvester", e);
System.exit(1);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

Expand All @@ -30,6 +32,9 @@
*/
@Component
public class NihmsTransformLoadCLIRunner implements CommandLineRunner {

private static final Logger LOG = LoggerFactory.getLogger(NihmsTransformLoadCLIRunner.class);

/**
* Request for help/usage documentation
*/
Expand Down Expand Up @@ -77,7 +82,6 @@ public void run(String... args) {
/* Handle general options such as help, version */
if (this.help) {
parser.printUsage(System.err);
System.err.println();
System.exit(0);
}

Expand All @@ -97,20 +101,11 @@ public void run(String... args) {
nihmsTransformLoadService.transformAndLoadFiles(statusesToProcess);

} catch (CmdLineException e) {
/**
* This is an error in command line args, just print out usage data
* and description of the error.
*/
System.err.println(e.getMessage());
parser.printUsage(System.err);
System.err.println();
System.exit(1);

} catch (Exception e) {
e.printStackTrace();
System.err.println(e.getMessage());
LOG.error("Error running Nihms Transform and Load", e);
System.exit(1);

}
}
}
Loading