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

#206 move maximum supported size of sbdh part to configuration #207

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.idea/
.settings/
target/
oxalis-as4.iml
output.mime
output.mime
/.classpath
/.project
11 changes: 10 additions & 1 deletion src/main/java/network/oxalis/as4/config/As4Conf.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,14 @@ public enum As4Conf {

@Path("oxalis.as4.type")
@DefaultValue("peppol")
TYPE
TYPE,

/**
* Defines maximum possible size of SBDH header in bytes. It is needed to limit
* parsing of SBD to prevent DOS attack, and be able to rewind the input
* stream to the start before passing it to persister.
*/
@Path("oxalis.as4.sbdh.limit")
@DefaultValue("65536")
SBDH_LIMIT
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
import network.oxalis.api.model.Direction;
import network.oxalis.api.model.TransmissionIdentifier;
import network.oxalis.api.persist.PersisterHandler;
import network.oxalis.api.settings.Settings;
import network.oxalis.api.timestamp.Timestamp;
import network.oxalis.api.timestamp.TimestampProvider;
import network.oxalis.api.transmission.TransmissionVerifier;
import network.oxalis.as4.common.As4MessageProperties;
import network.oxalis.as4.common.As4MessageProperty;
import network.oxalis.as4.config.As4Conf;
import network.oxalis.commons.header.SbdhHeaderParser;
import network.oxalis.commons.io.UnclosableInputStream;
import network.oxalis.vefa.peppol.common.code.DigestMethod;
Expand Down Expand Up @@ -63,16 +65,18 @@ public class As4InboundHandler {
private final As4MessageFactory as4MessageFactory;
private final PolicyService policyService;
private final InboundService inboundService;
private final Settings<As4Conf> as4Settings;

@Inject
public As4InboundHandler(TransmissionVerifier transmissionVerifier, PersisterHandler persisterHandler, TimestampProvider timestampProvider, HeaderParser headerParser, As4MessageFactory as4MessageFactory, PolicyService policyService, InboundService inboundService) {
public As4InboundHandler(TransmissionVerifier transmissionVerifier, PersisterHandler persisterHandler, TimestampProvider timestampProvider, HeaderParser headerParser, As4MessageFactory as4MessageFactory, PolicyService policyService, InboundService inboundService, Settings<As4Conf> as4Settings) {
this.transmissionVerifier = transmissionVerifier;
this.persisterHandler = persisterHandler;
this.timestampProvider = timestampProvider;
this.headerParser = headerParser;
this.as4MessageFactory = as4MessageFactory;
this.policyService = policyService;
this.inboundService = inboundService;
this.as4Settings = as4Settings;
}

public SOAPMessage handle(SOAPMessage request, MessageContext messageContext) throws OxalisAs4Exception {
Expand Down Expand Up @@ -359,7 +363,7 @@ private LinkedHashMap<InputStream, As4PayloadHeader> parseAttachments(Iterator<A

Header sbdh;
if (headerParser instanceof SbdhHeaderParser) {
bis.mark(65536);
bis.mark(as4Settings.getInt(As4Conf.SBDH_LIMIT));
sbdh = readHeader(contentId, bis);
bis.reset();
} else {
Expand Down