-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make csp config more robust such that its can also be disabled * Update static build mock path * Update env sample
- Loading branch information
1 parent
0c6fab3
commit 0589a02
Showing
6 changed files
with
77 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,8 +33,10 @@ EXPRESS_MAXIMUM_LOGS_FILE_SIZE=5242880 # 5MB | |
EXPRESS_MAXIMUM_LOG_FILES_NUMBER=5 | ||
EXPRESS_LOGS_FILE_PATH='/home/.express/reveal-express-server.log | ||
|
||
# https://github.com/helmetjs/helmet#reference | ||
# https://github.com/onaio/express-server/blob/f93e6120c683ca2ada29e0e0fa1c99cf0726f5ec/src/configs/settings.ts#L3C15-L3C15 | ||
EXPRESS_CONTENT_SECURITY_POLICY_CONFIG=`{"default-src":["'self'", "smartregister.org", "github.com"]}` | ||
EXPRESS_CONTENT_SECURITY_POLICY_CONFIG=`{"default-src":["'self'", "smartregister.org", "github.com"], useDefaults:false, reportOnly: true}` | ||
EXPRESS_CONTENT_SECURITY_POLICY_CONFIG=`false` | ||
|
||
EXPRESS_REDIS_STAND_ALONE_URL=redis://username:[email protected]:6379/4 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { EXPRESS_CONTENT_SECURITY_POLICY_CONFIG } from './envs'; | ||
|
||
export type CspSettings = Record<string, null | Iterable<string>> & { | ||
useDefaults?: boolean; | ||
reportOnly?: boolean; | ||
}; | ||
|
||
/** parse and return helmets' csp policy from an env string */ | ||
export const readCspOptionsConfig = () => { | ||
/** leave default behavior in place as the default, to disable env, dev needs to pass false as the value */ | ||
if (EXPRESS_CONTENT_SECURITY_POLICY_CONFIG === undefined) { | ||
return {}; | ||
} | ||
if (EXPRESS_CONTENT_SECURITY_POLICY_CONFIG === 'false') { | ||
return false; | ||
} | ||
const cspConfig = JSON.parse(EXPRESS_CONTENT_SECURITY_POLICY_CONFIG) as CspSettings; | ||
const { useDefaults, reportOnly, ...rest } = cspConfig; | ||
return { directives: rest, useDefaults, reportOnly }; | ||
}; |