Skip to content

Commit

Permalink
Add cspReportPath parameter such that it can
Browse files Browse the repository at this point in the history
be set from the outside when serving
  • Loading branch information
tobiasso85 committed May 20, 2020
1 parent 70367fb commit bd2f2ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/middleware/MiddlewareManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ class MiddlewareManager {
defaultPolicy2IsReportOnly: true,
});
}
if (this.options.cspReportPath) {
Object.assign(oCspConfig, {
cspReportPath: this.options.cspReportPath
});
}
return () => {
return cspModule("sap-ui-xx-csp-policy", oCspConfig);
};
Expand Down
4 changes: 3 additions & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,15 @@ module.exports = {
* aim for (AKA 'target policies'), are send for any requested
* <code>*.html</code> file
* @param {boolean} [options.simpleIndex=false] Use a simplified view for the server directory listing
* @param {string} [options.cspReportPath] Enable csp report logging to the given path
* @returns {Promise<object>} Promise resolving once the server is listening.
* It resolves with an object containing the <code>port</code>,
* <code>h2</code>-flag and a <code>close</code> function,
* which can be used to stop the server.
*/
async serve(tree, {
port: requestedPort, changePortIfInUse = false, h2 = false, key, cert,
acceptRemoteConnections = false, sendSAPTargetCSP = false, simpleIndex = false
acceptRemoteConnections = false, sendSAPTargetCSP = false, simpleIndex = false, cspReportPath
}) {
const projectResourceCollections = resourceFactory.createCollectionsForTree(tree);

Expand All @@ -140,6 +141,7 @@ module.exports = {
resources,
options: {
sendSAPTargetCSP,
cspReportPath,
simpleIndex
}
});
Expand Down

0 comments on commit bd2f2ae

Please sign in to comment.