File tree Expand file tree Collapse file tree 6 files changed +113
-6
lines changed
Expand file tree Collapse file tree 6 files changed +113
-6
lines changed Original file line number Diff line number Diff line change 1+ Access /access_modules /
Original file line number Diff line number Diff line change 1+ schema_validate :
2+ @echo $(shell python3 scripts/clone_access_modules.py && python3 scripts/validator.py)
3+
14run_semgrep :
25 $(shell semgrep --error --config "p/cwe-top-25" --config "p/owasp-top-ten" --config "p/r2c-security-audit")
Original file line number Diff line number Diff line change 11{
2- "googleapi" : {
3- "SOCIAL_AUTH_GOOGLE_OAUTH2_KEY" : " " ,
4- "SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET" : " " ,
5- "SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS" : " "
6- }
7- }
2+ "googleapi" : {
3+ "SOCIAL_AUTH_GOOGLE_OAUTH2_KEY" : " " ,
4+ "SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET" : " " ,
5+ "SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS" : " "
6+ },
7+ "access_modules" : {
8+ "git_urls" : [
9+ " https://github.com/browserstack/enigma-public-access-modules.git"
10+ ]
11+ },
12+ "enigmaGroup" : {
13+ "MAIL_APPROVER_GROUPS" : [
14+ " devnull@browserstack.com"
15+ ]
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ {
2+ "$schema" : " https://json-schema.org/draft/2020-12/schema" ,
3+ "$id" : " /schemas/central" ,
4+ "title" : " Config" ,
5+ "description" : " The config file schema" ,
6+ "type" : " object" ,
7+ "properties" : {
8+ "googleapi" : {
9+ "description" : " Config keys related to Google SSO" ,
10+ "type" : " object" ,
11+ "properties" : {
12+ "SOCIAL_AUTH_GOOGLE_OAUTH2_KEY" : {
13+ "description" : " Google OAuth2 Key" ,
14+ "type" : " string"
15+ },
16+ "SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET" : {
17+ "description" : " Google OAuth2 secret" ,
18+ "type" : " string"
19+ },
20+ "SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS" : {
21+ "description" : " Google OAuth2 whitelisted domains" ,
22+ "type" : " string"
23+ }
24+ }
25+ },
26+ "access_modules" : {
27+ "description" : " List of access modules attached to this tool" ,
28+ "type" : " object" ,
29+ "properties" : {
30+ "git_urls" : {
31+ "description" : " List of git URLs of access modules" ,
32+ "type" : " array"
33+ }
34+ }
35+ },
36+ "enigmaGroup" :{
37+ "description" :" Config related of enigma groups" ,
38+ "type" :" object" ,
39+ "properties" :{
40+ "MAIL_APPROVER_GROUPS" :{
41+ "description" :" List of mail approvers" ,
42+ "type" :" array"
43+ }
44+ }
45+ }
46+ },
47+ "required" : [
48+ " googleapi"
49+ ]
50+ }
Original file line number Diff line number Diff line change 1+ import json
2+ import sys
3+ from git import Repo
4+
5+ try :
6+ f = open ("./config.json" ,"r" )
7+ config = json .load (f )
8+ urls = config ["access_modules" ]["git_urls" ]
9+ for url in urls :
10+ folder_name = url .split ("/" ).pop ()[:- 4 ]
11+ try :
12+ Repo .clone_from (url , "./Access/access_modules/" + folder_name )
13+ except Exception as e :
14+ print ("failed cloning " + folder_name + "." )
15+ except Exception as e :
16+ print ("Access module cloning failed!" )
17+ print (str (e ))
18+ sys .exit (1 )
Original file line number Diff line number Diff line change 1+ import json
2+ import os
3+ import sys
4+ from jsonschema import validate
5+
6+ try :
7+ f = open ("./schema.json" ,"r" )
8+ schema = json .load (f )
9+ f = open ("./config.json" , "r" )
10+ config = json .load (f )
11+ root_folders = [ f .path for f in os .scandir ("./Access/access_modules" ) if f .is_dir () ]
12+ for folder in root_folders :
13+ modules = [ f .path for f in os .scandir (folder ) if f .is_dir () ]
14+ for module in modules :
15+ if os .path .exists (module + "/schema.json" ):
16+ f = open (module + "/schema.json" )
17+ module_schema = json .load (f )
18+ schema ["properties" ].update (module_schema ["properties" ])
19+ schema ["required" ] += module_schema ["required" ]
20+ validate (instance = config , schema = schema )
21+ print ("Schema validation passed!" )
22+ except Exception as e :
23+ print ("Schema validation failed!" )
24+ print (e )
25+ sys .exit (1 )
You can’t perform that action at this time.
0 commit comments