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: missing base64 decoding in mpr controller #580

Merged
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 @@ -85,9 +85,13 @@
example = "true") @RequestParam boolean partnerSupplies,
@Parameter(description = "This boolean flag indicates whether this Partner is a potential customer of this Material.",
example = "true") @RequestParam boolean partnerBuys) {

ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber));
partnerMaterialNumber = new String(Base64.getDecoder().decode(partnerMaterialNumber));
try {
ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber));
partnerMaterialNumber = new String(Base64.getDecoder().decode(partnerMaterialNumber));
} catch (Exception e) {
log.error("parameters were not properly encoded in base64");
return new ResponseEntity<>(HttpStatusCode.valueOf(400));
}
if (!materialPattern.matcher(ownMaterialNumber).matches() || !materialPattern.matcher(partnerMaterialNumber).matches()
|| !bpnlPattern.matcher(partnerBpnl).matches()) {
log.warn("Rejected message parameters. ");
Expand Down Expand Up @@ -146,11 +150,16 @@
example = "true") @RequestParam(required = false) Boolean partnerSupplies,
@Parameter(description = "This boolean flag indicates whether this Partner is a potential customer of this Material.",
example = "true") @RequestParam(required = false) Boolean partnerBuys) {
ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber));
try {
ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber));
partnerMaterialNumber = new String(Base64.getDecoder().decode(partnerMaterialNumber));
} catch (Exception e) {
log.error("parameters were not properly encoded in base64");
return new ResponseEntity<>(HttpStatusCode.valueOf(400));
}
MaterialPartnerRelation existingRelation = null;

if (!bpnlPattern.matcher(partnerBpnl).matches() || !materialPattern.matcher(ownMaterialNumber).matches() ||
(partnerMaterialNumber != null && !materialPattern.matcher(partnerMaterialNumber).matches())) {

Check warning

Code scanning / CodeQL

Useless null check Warning

This check is useless.
partnerMaterialNumber
cannot be null at this check, since
new String(...)
always is non-null.
log.warn("Rejected message parameters. ");
return new ResponseEntity<>(HttpStatusCode.valueOf(400));
}
Expand All @@ -169,7 +178,7 @@
if (partnerBuys != null) {
existingRelation.setPartnerBuysMaterial(partnerBuys);
}
if (partnerMaterialNumber != null) {

Check warning

Code scanning / CodeQL

Useless null check Warning

This check is useless.
partnerMaterialNumber
cannot be null at this check, since
new String(...)
always is non-null.
existingRelation.setPartnerMaterialNumber(partnerMaterialNumber);
}
if (nameAtManufacturer != null) {
Expand Down
Loading