fix(back-end): fix security issue
Some checks failed
Build and Deploy / test-backend (push) Successful in 25s
PR Checks / prettier-autofix (pull_request) Successful in 8s
PR Checks / security-sast (pull_request) Failing after 29s
Build and Deploy / test-frontend (push) Successful in 1m5s
PR Checks / test-backend (pull_request) Successful in 27s
Build and Deploy / build-and-push (push) Successful in 37s
PR Checks / test-frontend (pull_request) Successful in 1m5s
Build and Deploy / deploy (push) Successful in 12s
Some checks failed
Build and Deploy / test-backend (push) Successful in 25s
PR Checks / prettier-autofix (pull_request) Successful in 8s
PR Checks / security-sast (pull_request) Failing after 29s
Build and Deploy / test-frontend (push) Successful in 1m5s
PR Checks / test-backend (pull_request) Successful in 27s
Build and Deploy / build-and-push (push) Successful in 37s
PR Checks / test-frontend (pull_request) Successful in 1m5s
Build and Deploy / deploy (push) Successful in 12s
This commit is contained in:
@@ -639,9 +639,9 @@ public class SlicerService {
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
dbf.setNamespaceAware(true);
|
||||
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
|
||||
disableIfSupported(dbf, "http://apache.org/xml/features/disallow-doctype-decl");
|
||||
disableIfSupported(dbf, "http://xml.org/sax/features/external-general-entities");
|
||||
disableIfSupported(dbf, "http://xml.org/sax/features/external-parameter-entities");
|
||||
setFeatureIfSupported(dbf, "http://apache.org/xml/features/disallow-doctype-decl", true);
|
||||
setFeatureIfSupported(dbf, "http://xml.org/sax/features/external-general-entities", false);
|
||||
setFeatureIfSupported(dbf, "http://xml.org/sax/features/external-parameter-entities", false);
|
||||
dbf.setXIncludeAware(false);
|
||||
dbf.setExpandEntityReferences(false);
|
||||
|
||||
@@ -650,9 +650,9 @@ public class SlicerService {
|
||||
}
|
||||
}
|
||||
|
||||
private void disableIfSupported(DocumentBuilderFactory dbf, String feature) {
|
||||
private void setFeatureIfSupported(DocumentBuilderFactory dbf, String feature, boolean enabled) {
|
||||
try {
|
||||
dbf.setFeature(feature, false);
|
||||
dbf.setFeature(feature, enabled);
|
||||
} catch (Exception ignored) {
|
||||
// Best-effort hardening.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user