From 61a858c1755f5439bfcc862ee9a06ed5a842767e Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 8 Jan 2024 08:13:44 -0800 Subject: [PATCH 001/197] Release/0.2.0 beta/test 1 (#456) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index bb221109..7d21f73e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,7 +51,7 @@ pipeline { stage('Unit Testing') { agent { docker { - image 'securityuniversal/jenkins-python-agent:latest' + image 'securityuniversal/jenkins:latest' } } when { From 3c06d22040399db5e89b30f2f0a9dbb7c13f164d Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 8 Jan 2024 13:26:41 -0800 Subject: [PATCH 002/197] Release/0.2.0 beta/test 1 (#458) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7d21f73e..1fffa348 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -99,7 +99,7 @@ pipeline { stage('Software Composition Analysis') { agent { docker { - image 'securityuniversal/jenkins-codetesting-agent:latest' + image 'securityuniversal/jenkins:latest' } } when { @@ -127,7 +127,7 @@ pipeline { stage('Static Application Security Testing') { agent { docker { - image 'securityuniversal/jenkins-codetesting-agent:latest' + image 'securityuniversal/jenkins:latest' } } when { From 2048a736b2550139374cd4ca5e5aed589546581e Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 8 Jan 2024 14:36:28 -0800 Subject: [PATCH 003/197] Release/0.2.0 beta/test 1 (#460) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml --- pipeline-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline-config.yaml b/pipeline-config.yaml index 9d98c47f..68f8f7cf 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -23,7 +23,7 @@ stages: - Python - Javascript sast: - enabled: true + enabled: false branches: - release codeLanguages: From fd72e21852e64004f58976e101ea8976c86ced37 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 8 Jan 2024 15:07:51 -0800 Subject: [PATCH 004/197] Release/0.2.0 beta/test 1 (#462) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml --- pipeline-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pipeline-config.yaml b/pipeline-config.yaml index 68f8f7cf..2b33b743 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -9,14 +9,14 @@ stages: branches: - release unitTesting: - enabled: true + enabled: false branches: [] secretScanning: enabled: true branches: - release sca: - enabled: true + enabled: false branches: - release codeLanguages: @@ -37,19 +37,19 @@ stages: branches: - release containerScan: - enabled: true + enabled: false branches: - release containerName: secusphere containerTag: latest releaseToTest: - enabled: true + enabled: false branches: - release serviceName: secusphere containerTag: latest testRelease: - enabled: true + enabled: false branches: - release targetUrl: 'http://192.168.0.68:5010' From 7e019fe2605dcef34f9667981fd01b95a5efe26e Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 8 Jan 2024 15:14:20 -0800 Subject: [PATCH 005/197] Release/0.2.0 beta/test 1 (#464) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml --- pipeline-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline-config.yaml b/pipeline-config.yaml index 2b33b743..c54451b7 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -56,7 +56,7 @@ stages: dastTestType: full apiTargetUrl: 'http://192.168.0.68:5010/api/openapi.yaml' securityQualityGate: - enabled: true + enabled: false branches: - release deploy: From bf129376027b8bed489da0f7f1fcd5ba0227368a Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 8 Jan 2024 15:25:54 -0800 Subject: [PATCH 006/197] Release/0.2.0 beta/test 1 (#466) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 1fffa348..a0e0cd5d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -316,6 +316,7 @@ pipeline { agent { docker { image 'securityuniversal/jenkins-deploy-agent:latest' + args '--group-add 999' } } when { From cb6f25a1a5b245dd708d06a9bc4290b1ea9a1676 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Wed, 10 Jan 2024 10:00:00 -0800 Subject: [PATCH 007/197] Release/0.2.0 beta/test 1 (#468) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py --- src/vr/vulns/model/sgglobalthresholds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vr/vulns/model/sgglobalthresholds.py b/src/vr/vulns/model/sgglobalthresholds.py index 0309bae3..09a2d3f1 100644 --- a/src/vr/vulns/model/sgglobalthresholds.py +++ b/src/vr/vulns/model/sgglobalthresholds.py @@ -8,7 +8,7 @@ class SgGlobalThresholds(db.Model): __tablename__ = 'SgGlobalThresholds' __table_args__ = {'extend_existing': True} ID = db.Column(db.Integer, primary_key=True) - Name = db.Column(db.String) + Name = db.Column(db.String(100)) AddDate = db.Column(db.DateTime) ThreshScaLow = db.Column(db.Integer) ThreshScaMedium = db.Column(db.Integer) From 5c923878ba0d8e7c1068c71e577e073f2eff2f5c Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Wed, 10 Jan 2024 10:21:40 -0800 Subject: [PATCH 008/197] Release/0.2.0 beta/test 1 (#470) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py --- src/vr/functions/initial_setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vr/functions/initial_setup.py b/src/vr/functions/initial_setup.py index abc1228d..1132f9c9 100644 --- a/src/vr/functions/initial_setup.py +++ b/src/vr/functions/initial_setup.py @@ -217,7 +217,7 @@ def setup_core_db_tables(ENV): if ENV == 'test': sql = 'INSERT INTO SgGlobalThresholds (Name, AddDate, ThreshScaLow, ThreshScaMedium, ThreshScaHigh, ThreshScaCritical, ThreshContainerLow, ThreshContainerMedium, ThreshContainerHigh, ThreshContainerCritical, ThreshDastLow, ThreshDastMedium, ThreshDastHigh, ThreshDastCritical, ThreshDastApiLow, ThreshDastApiMedium, ThreshDastApiHigh, ThreshDastApiCritical, ThreshInfrastructureLow, ThreshInfrastructureMedium, ThreshInfrastructureHigh, ThreshInfrastructureCritical, ThreshSastLow, ThreshSastMedium, ThreshSastHigh, ThreshSastCritical, ThreshIacLow, ThreshIacMedium, ThreshIacHigh, ThreshIacCritical, ThreshSecretsLow, ThreshSecretsMedium, ThreshSecretsHigh, ThreshSecretsCritical) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)' else: - sql = 'INSERT INTO SgGlobalThresholds (Name, AddDate, ThreshScaLow, ThreshScaMedium, ThreshScaHigh, ThreshScaCritical, ThreshContainerLow, ThreshContainerMedium, ThreshContainerHigh, ThreshContainerCritical, ThreshDastLow, ThreshDastMedium, ThreshDastHigh, ThreshDastCritical, ThreshDastApiLow, ThreshDastApiMedium, ThreshDastApiHigh, ThreshDastApiCritical, ThreshInfrastructureLow, ThreshInfrastructureMedium, ThreshInfrastructureHigh, ThreshInfrastructureCritical, ThreshSastLow, ThreshSastMedium, ThreshSastHigh, ThreshSastCritical, ThreshIacLow, ThreshIacMedium, ThreshIacHigh, ThreshIacCritical, ThreshSecretsLow, ThreshSecretsMedium, ThreshSecretsHigh, ThreshSecretsCritical) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)' + sql = 'INSERT INTO SgGlobalThresholds (Name, AddDate, ThreshScaLow, ThreshScaMedium, ThreshScaHigh, ThreshScaCritical, ThreshContainerLow, ThreshContainerMedium, ThreshContainerHigh, ThreshContainerCritical, ThreshDastLow, ThreshDastMedium, ThreshDastHigh, ThreshDastCritical, ThreshDastApiLow, ThreshDastApiMedium, ThreshDastApiHigh, ThreshDastApiCritical, ThreshInfrastructureLow, ThreshInfrastructureMedium, ThreshInfrastructureHigh, ThreshInfrastructureCritical, ThreshSastLow, ThreshSastMedium, ThreshSastHigh, ThreshSastCritical, ThreshIacLow, ThreshIacMedium, ThreshIacHigh, ThreshIacCritical, ThreshSecretsLow, ThreshSecretsMedium, ThreshSecretsHigh, ThreshSecretsCritical) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)' args = ("General", now, None,None,4,0,None,None,2,0,None,None,0,2,None,None,0,2,None,None,0,2,None,None,0,2,None,None,0,2,None,None,0,2) cur.execute(sql, args) db.commit() From d0edd8f43198c3e36fe21e092a87b05a5679668a Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 12 Jan 2024 20:34:28 -0800 Subject: [PATCH 009/197] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index a0e0cd5d..d2593530 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -326,7 +326,7 @@ pipeline { // Condition for a Test-* branch expression { // Split the branch name by '/' and check if the last segment starts with 'Test-' - env.BRANCH_NAME.split('/').last().startsWith('Test') + env.BRANCH_NAME.split('/').last().startsWith('staging') } } } From 6bc2607e607869e15e8ed4e2814f5428b1a7ccc1 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 12 Jan 2024 22:06:35 -0800 Subject: [PATCH 010/197] Update pipeline-config.yaml --- pipeline-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/pipeline-config.yaml b/pipeline-config.yaml index c54451b7..2267ddc6 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -75,6 +75,7 @@ stages: azure.azTenantId: 'azTenantId' serviceCredentials: {} serviceSetStrings: + app.env: test app.extUrl: "192.168.0.150" app.db.prodDbUriRef: "PROD-DB-URI" app.smtp.host: "smtp.sendgrid.net:587" From 4e2bc4af7db96e100b2dfa52480a626b9046cabb Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 12 Jan 2024 22:22:47 -0800 Subject: [PATCH 011/197] Update values.yaml --- ci_cd/helm/secusphere/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci_cd/helm/secusphere/values.yaml b/ci_cd/helm/secusphere/values.yaml index 8f2bcf7d..abba5342 100644 --- a/ci_cd/helm/secusphere/values.yaml +++ b/ci_cd/helm/secusphere/values.yaml @@ -3,7 +3,7 @@ # Declare variables to be passed into your templates. environment: prod appName: "secusphere" -appDomain: "acme.com" +appDomain: "securityuniversal.com" tlsSecretName: su-wildcard-tls From fba2f2bcd1453922682cc605c3e0387e43d12dfe Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 12 Jan 2024 23:10:34 -0800 Subject: [PATCH 012/197] Update values.yaml --- ci_cd/helm/su-secrets/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci_cd/helm/su-secrets/values.yaml b/ci_cd/helm/su-secrets/values.yaml index 3bba9d33..97c59f40 100644 --- a/ci_cd/helm/su-secrets/values.yaml +++ b/ci_cd/helm/su-secrets/values.yaml @@ -8,6 +8,6 @@ azure: tls: enabled: true - name: "dynamic" + name: "su-wildcard-tls" crt: "dynamic" key: "dynamic" From 1a298c05ea84e93dc9eda4314e6796a6e11abe7b Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sun, 14 Jan 2024 23:13:47 -0800 Subject: [PATCH 013/197] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d2593530..b45f5c3d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -326,7 +326,7 @@ pipeline { // Condition for a Test-* branch expression { // Split the branch name by '/' and check if the last segment starts with 'Test-' - env.BRANCH_NAME.split('/').last().startsWith('staging') + env.BRANCH_NAME.split('/').last().startsWith('staging') || env.BRANCH_NAME.split('/').last().startsWith('Prod') } } } From ef00ba59f8b78977252d313d3a83725d9c4e852d Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 15 Jan 2024 08:39:41 -0800 Subject: [PATCH 014/197] Update values.yaml --- ci_cd/helm/secusphere/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci_cd/helm/secusphere/values.yaml b/ci_cd/helm/secusphere/values.yaml index abba5342..8a4fce89 100644 --- a/ci_cd/helm/secusphere/values.yaml +++ b/ci_cd/helm/secusphere/values.yaml @@ -83,7 +83,7 @@ volumes: claimName: su-webapp-pv-claim ingress: - enabled: true + enabled: false serviceAccount: # Specifies whether a service account should be created From f497be3383606476ced847f9fef26186d372ab51 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 16 Jan 2024 17:19:36 -0800 Subject: [PATCH 015/197] Update pipeline-config.yaml --- pipeline-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pipeline-config.yaml b/pipeline-config.yaml index 2267ddc6..daaeead8 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -75,14 +75,14 @@ stages: azure.azTenantId: 'azTenantId' serviceCredentials: {} serviceSetStrings: - app.env: test - app.extUrl: "192.168.0.150" + app.env: prod + app.extUrl: "secusphere.securityuniversal.com" app.db.prodDbUriRef: "PROD-DB-URI" app.smtp.host: "smtp.sendgrid.net:587" app.smtp.user: apikey app.smtp.adminEmail: "admin@securityuniversal.com" - app.smtp.passwordRef: "SENDGRID-SMTP-PW" - app.az.keyVaultName: "BkDevSecOpsKeyVault" + app.smtp.passwordRef: "SMTP-PW" + app.az.keyVaultName: "ss-keyvault" post: enabled: true branches: From 89910f9e41767e491c37fd43983b34e16d11f326 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 16 Jan 2024 20:28:00 -0800 Subject: [PATCH 016/197] Release/0.2.0 beta/staging (#472) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Feature/jenkinsfile updates (#471) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations --- Jenkinsfile | 2 +- ci_cd/helm/secusphere/values.yaml | 2 +- ci_cd/helm/su-secrets/values.yaml | 2 +- pipeline-config.yaml | 1 + src/config_engine.py | 130 +++++++++++++++++------------- src/settings.py | 2 + src/vr/templates/base_auth.html | 1 + 7 files changed, 83 insertions(+), 57 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a0e0cd5d..d2593530 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -326,7 +326,7 @@ pipeline { // Condition for a Test-* branch expression { // Split the branch name by '/' and check if the last segment starts with 'Test-' - env.BRANCH_NAME.split('/').last().startsWith('Test') + env.BRANCH_NAME.split('/').last().startsWith('staging') } } } diff --git a/ci_cd/helm/secusphere/values.yaml b/ci_cd/helm/secusphere/values.yaml index 8f2bcf7d..abba5342 100644 --- a/ci_cd/helm/secusphere/values.yaml +++ b/ci_cd/helm/secusphere/values.yaml @@ -3,7 +3,7 @@ # Declare variables to be passed into your templates. environment: prod appName: "secusphere" -appDomain: "acme.com" +appDomain: "securityuniversal.com" tlsSecretName: su-wildcard-tls diff --git a/ci_cd/helm/su-secrets/values.yaml b/ci_cd/helm/su-secrets/values.yaml index 3bba9d33..97c59f40 100644 --- a/ci_cd/helm/su-secrets/values.yaml +++ b/ci_cd/helm/su-secrets/values.yaml @@ -8,6 +8,6 @@ azure: tls: enabled: true - name: "dynamic" + name: "su-wildcard-tls" crt: "dynamic" key: "dynamic" diff --git a/pipeline-config.yaml b/pipeline-config.yaml index c54451b7..2267ddc6 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -75,6 +75,7 @@ stages: azure.azTenantId: 'azTenantId' serviceCredentials: {} serviceSetStrings: + app.env: test app.extUrl: "192.168.0.150" app.db.prodDbUriRef: "PROD-DB-URI" app.smtp.host: "smtp.sendgrid.net:587" diff --git a/src/config_engine.py b/src/config_engine.py index 0168cb9a..07400d06 100644 --- a/src/config_engine.py +++ b/src/config_engine.py @@ -9,7 +9,7 @@ SET_APP_EXT_URL from settings import SET_PROD_DB_URI_REF, SET_SMTP_PW_REF, SET_JENKINS_KEY_REF, SET_JENKINS_USER_REF, SET_JENKINS_TOKEN_REF from settings import SET_PROD_DB_URI, SET_SMTP_PW, SET_JENKINS_KEY, SET_JENKINS_USER, \ - SET_JENKINS_HOST, SET_JENKINS_PROJECT, SET_JENKINS_TOKEN, SET_JENKINS_STAGING_PROJECT + SET_JENKINS_HOST, SET_JENKINS_PROJECT, SET_JENKINS_TOKEN, SET_JENKINS_STAGING_PROJECT, SET_JENKINS_ENABLED, SET_SNOW_ENABLED from settings import SET_AZAD_CLIENT_ID, SET_AZAD_CLIENT_SECRET, SET_AZAD_AUTHORITY from settings import SET_SNOW_INSTANCE_NAME, SET_SNOW_CLIENT_ID, SET_SNOW_CLIENT_SECRET, SET_SNOW_USERNAME, SET_SNOW_PASSWORD, SET_SNOW_CLIENT_SECRET_REF, SET_SNOW_PASSWORD_REF @@ -205,65 +205,87 @@ def delete_cert(self, secret_name): ## ## GitHub to Jenkins Webhook ## -if ENV == 'prod': - if os.getenv('JENKINS_USER'): - JENKINS_USER = KeyVaultManager().get_secret(os.getenv('JENKINS_USER')) - else: - JENKINS_USER = KeyVaultManager().get_secret(SET_JENKINS_USER_REF) - if os.getenv('JENKINS_KEY'): - JENKINS_KEY = KeyVaultManager().get_secret(os.getenv('JENKINS_KEY')) - else: - JENKINS_KEY = KeyVaultManager().get_secret(SET_JENKINS_KEY_REF) - if os.getenv('JENKINS_TOKEN'): - JENKINS_TOKEN = KeyVaultManager().get_secret(os.getenv('JENKINS_TOKEN')) - else: - JENKINS_TOKEN = KeyVaultManager().get_secret(SET_JENKINS_TOKEN_REF) +if os.getenv('JENKINS_ENABLED'): + JENKINS_ENABLED = os.getenv('JENKINS_ENABLED') else: - JENKINS_USER = SET_JENKINS_USER - JENKINS_KEY = SET_JENKINS_KEY - JENKINS_TOKEN = SET_JENKINS_TOKEN + JENKINS_ENABLED = SET_JENKINS_ENABLED +if JENKINS_ENABLED == 'yes': + if ENV == 'prod': + if os.getenv('JENKINS_USER'): + JENKINS_USER = KeyVaultManager().get_secret(os.getenv('JENKINS_USER')) + else: + JENKINS_USER = KeyVaultManager().get_secret(SET_JENKINS_USER_REF) + if os.getenv('JENKINS_KEY'): + JENKINS_KEY = KeyVaultManager().get_secret(os.getenv('JENKINS_KEY')) + else: + JENKINS_KEY = KeyVaultManager().get_secret(SET_JENKINS_KEY_REF) + if os.getenv('JENKINS_TOKEN'): + JENKINS_TOKEN = KeyVaultManager().get_secret(os.getenv('JENKINS_TOKEN')) + else: + JENKINS_TOKEN = KeyVaultManager().get_secret(SET_JENKINS_TOKEN_REF) + else: + JENKINS_USER = SET_JENKINS_USER + JENKINS_KEY = SET_JENKINS_KEY + JENKINS_TOKEN = SET_JENKINS_TOKEN -if os.getenv('JENKINS_PROJECT'): - JENKINS_PROJECT = os.getenv('JENKINS_PROJECT') -else: - JENKINS_PROJECT = SET_JENKINS_PROJECT + if os.getenv('JENKINS_PROJECT'): + JENKINS_PROJECT = os.getenv('JENKINS_PROJECT') + else: + JENKINS_PROJECT = SET_JENKINS_PROJECT -if os.getenv('JENKINS_HOST'): - JENKINS_HOST = os.getenv('JENKINS_HOST') -else: - JENKINS_HOST = SET_JENKINS_HOST + if os.getenv('JENKINS_HOST'): + JENKINS_HOST = os.getenv('JENKINS_HOST') + else: + JENKINS_HOST = SET_JENKINS_HOST -if os.getenv('JENKINS_STAGING_PROJECT'): - JENKINS_STAGING_PROJECT = os.getenv('JENKINS_STAGING_PROJECT') + if os.getenv('JENKINS_STAGING_PROJECT'): + JENKINS_STAGING_PROJECT = os.getenv('JENKINS_STAGING_PROJECT') + else: + JENKINS_STAGING_PROJECT = SET_JENKINS_STAGING_PROJECT else: - JENKINS_STAGING_PROJECT = SET_JENKINS_STAGING_PROJECT - + JENKINS_USER = "" + JENKINS_KEY = "" + JENKINS_TOKEN = "" + JENKINS_PROJECT = "" + JENKINS_HOST = "" + JENKINS_STAGING_PROJECT = "" ## ServiceNOW Integration -if ENV == 'prod': - if os.getenv('SNOW_PASSWORD'): - SNOW_PASSWORD = KeyVaultManager().get_secret(os.getenv('SNOW_PASSWORD')) - else: - SNOW_PASSWORD = KeyVaultManager().get_secret(SET_SNOW_PASSWORD_REF) - if os.getenv('SNOW_CLIENT_SECRET'): - SNOW_CLIENT_SECRET = KeyVaultManager().get_secret(os.getenv('SNOW_CLIENT_SECRET')) - else: - SNOW_CLIENT_SECRET = KeyVaultManager().get_secret(SET_SNOW_CLIENT_SECRET_REF) - if os.getenv('SNOW_INSTANCE_NAME'): - SNOW_INSTANCE_NAME = KeyVaultManager().get_secret(os.getenv('SNOW_INSTANCE_NAME')) - else: - SNOW_INSTANCE_NAME = KeyVaultManager().get_secret(SET_SNOW_INSTANCE_NAME) - if os.getenv('SNOW_CLIENT_ID'): - SNOW_CLIENT_ID = KeyVaultManager().get_secret(os.getenv('SNOW_CLIENT_ID')) - else: - SNOW_CLIENT_ID = KeyVaultManager().get_secret(SET_SNOW_CLIENT_ID) - if os.getenv('SNOW_USERNAME'): - SNOW_USERNAME = KeyVaultManager().get_secret(os.getenv('SNOW_USERNAME')) +if os.getenv('SNOW_ENABLED'): + SNOW_ENABLED = os.getenv('SNOW_ENABLED') +else: + SNOW_ENABLED = SET_SNOW_ENABLED +if SNOW_ENABLED == 'yes': + if ENV == 'prod': + if os.getenv('SNOW_PASSWORD'): + SNOW_PASSWORD = KeyVaultManager().get_secret(os.getenv('SNOW_PASSWORD')) + else: + SNOW_PASSWORD = KeyVaultManager().get_secret(SET_SNOW_PASSWORD_REF) + if os.getenv('SNOW_CLIENT_SECRET'): + SNOW_CLIENT_SECRET = KeyVaultManager().get_secret(os.getenv('SNOW_CLIENT_SECRET')) + else: + SNOW_CLIENT_SECRET = KeyVaultManager().get_secret(SET_SNOW_CLIENT_SECRET_REF) + if os.getenv('SNOW_INSTANCE_NAME'): + SNOW_INSTANCE_NAME = os.getenv('SNOW_INSTANCE_NAME') + else: + SNOW_INSTANCE_NAME = SET_SNOW_INSTANCE_NAME + if os.getenv('SNOW_CLIENT_ID'): + SNOW_CLIENT_ID = os.getenv('SNOW_CLIENT_ID') + else: + SNOW_CLIENT_ID = SET_SNOW_CLIENT_ID + if os.getenv('SNOW_USERNAME'): + SNOW_USERNAME = os.getenv('SNOW_USERNAME') + else: + SNOW_USERNAME = SET_SNOW_USERNAME else: - SNOW_USERNAME = KeyVaultManager().get_secret(SET_SNOW_USERNAME) + SNOW_PASSWORD = SET_SNOW_PASSWORD + SNOW_CLIENT_SECRET = SET_SNOW_CLIENT_SECRET + SNOW_INSTANCE_NAME = SET_SNOW_INSTANCE_NAME + SNOW_CLIENT_ID = SET_SNOW_CLIENT_ID + SNOW_USERNAME = SET_SNOW_USERNAME else: - SNOW_PASSWORD = SET_SNOW_PASSWORD - SNOW_CLIENT_SECRET = SET_SNOW_CLIENT_SECRET - SNOW_INSTANCE_NAME = SET_SNOW_INSTANCE_NAME - SNOW_CLIENT_ID = SET_SNOW_CLIENT_ID - SNOW_USERNAME = SET_SNOW_USERNAME + SNOW_PASSWORD = "" + SNOW_CLIENT_SECRET = "" + SNOW_INSTANCE_NAME = "" + SNOW_CLIENT_ID = "" + SNOW_USERNAME = "" diff --git a/src/settings.py b/src/settings.py index 7273b90b..a893a2f0 100644 --- a/src/settings.py +++ b/src/settings.py @@ -39,6 +39,7 @@ ## ## Jenkins Webhook Settings (Optional) ## +SET_JENKINS_ENABLED = 'no' SET_JENKINS_KEY_REF = 'JENKINS-KEY' SET_JENKINS_USER_REF = 'JENKINS-USER' SET_JENKINS_TOKEN_REF = 'JENKINS-TOKEN' @@ -51,6 +52,7 @@ SET_JENKINS_TOKEN = 'changeme' ## ServiceNOW Settings +SET_SNOW_ENABLED = 'no' SET_SNOW_INSTANCE_NAME = 'dev124268' SET_SNOW_CLIENT_ID = '1ab21bf476013110e1ce39e1f368c2fa' SET_SNOW_CLIENT_SECRET_REF = 'SNOW-SECRET' diff --git a/src/vr/templates/base_auth.html b/src/vr/templates/base_auth.html index 5886557d..df697bc2 100644 --- a/src/vr/templates/base_auth.html +++ b/src/vr/templates/base_auth.html @@ -15,6 +15,7 @@ + From ee6d9dd0bfb3c7ffd9ad26ff43ee391f3443ced6 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 16 Jan 2024 20:29:15 -0800 Subject: [PATCH 017/197] Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations --- src/config_engine.py | 130 +++++++++++++++++++------------- src/settings.py | 2 + src/vr/templates/base_auth.html | 1 + 3 files changed, 79 insertions(+), 54 deletions(-) diff --git a/src/config_engine.py b/src/config_engine.py index 0168cb9a..07400d06 100644 --- a/src/config_engine.py +++ b/src/config_engine.py @@ -9,7 +9,7 @@ SET_APP_EXT_URL from settings import SET_PROD_DB_URI_REF, SET_SMTP_PW_REF, SET_JENKINS_KEY_REF, SET_JENKINS_USER_REF, SET_JENKINS_TOKEN_REF from settings import SET_PROD_DB_URI, SET_SMTP_PW, SET_JENKINS_KEY, SET_JENKINS_USER, \ - SET_JENKINS_HOST, SET_JENKINS_PROJECT, SET_JENKINS_TOKEN, SET_JENKINS_STAGING_PROJECT + SET_JENKINS_HOST, SET_JENKINS_PROJECT, SET_JENKINS_TOKEN, SET_JENKINS_STAGING_PROJECT, SET_JENKINS_ENABLED, SET_SNOW_ENABLED from settings import SET_AZAD_CLIENT_ID, SET_AZAD_CLIENT_SECRET, SET_AZAD_AUTHORITY from settings import SET_SNOW_INSTANCE_NAME, SET_SNOW_CLIENT_ID, SET_SNOW_CLIENT_SECRET, SET_SNOW_USERNAME, SET_SNOW_PASSWORD, SET_SNOW_CLIENT_SECRET_REF, SET_SNOW_PASSWORD_REF @@ -205,65 +205,87 @@ def delete_cert(self, secret_name): ## ## GitHub to Jenkins Webhook ## -if ENV == 'prod': - if os.getenv('JENKINS_USER'): - JENKINS_USER = KeyVaultManager().get_secret(os.getenv('JENKINS_USER')) - else: - JENKINS_USER = KeyVaultManager().get_secret(SET_JENKINS_USER_REF) - if os.getenv('JENKINS_KEY'): - JENKINS_KEY = KeyVaultManager().get_secret(os.getenv('JENKINS_KEY')) - else: - JENKINS_KEY = KeyVaultManager().get_secret(SET_JENKINS_KEY_REF) - if os.getenv('JENKINS_TOKEN'): - JENKINS_TOKEN = KeyVaultManager().get_secret(os.getenv('JENKINS_TOKEN')) - else: - JENKINS_TOKEN = KeyVaultManager().get_secret(SET_JENKINS_TOKEN_REF) +if os.getenv('JENKINS_ENABLED'): + JENKINS_ENABLED = os.getenv('JENKINS_ENABLED') else: - JENKINS_USER = SET_JENKINS_USER - JENKINS_KEY = SET_JENKINS_KEY - JENKINS_TOKEN = SET_JENKINS_TOKEN + JENKINS_ENABLED = SET_JENKINS_ENABLED +if JENKINS_ENABLED == 'yes': + if ENV == 'prod': + if os.getenv('JENKINS_USER'): + JENKINS_USER = KeyVaultManager().get_secret(os.getenv('JENKINS_USER')) + else: + JENKINS_USER = KeyVaultManager().get_secret(SET_JENKINS_USER_REF) + if os.getenv('JENKINS_KEY'): + JENKINS_KEY = KeyVaultManager().get_secret(os.getenv('JENKINS_KEY')) + else: + JENKINS_KEY = KeyVaultManager().get_secret(SET_JENKINS_KEY_REF) + if os.getenv('JENKINS_TOKEN'): + JENKINS_TOKEN = KeyVaultManager().get_secret(os.getenv('JENKINS_TOKEN')) + else: + JENKINS_TOKEN = KeyVaultManager().get_secret(SET_JENKINS_TOKEN_REF) + else: + JENKINS_USER = SET_JENKINS_USER + JENKINS_KEY = SET_JENKINS_KEY + JENKINS_TOKEN = SET_JENKINS_TOKEN -if os.getenv('JENKINS_PROJECT'): - JENKINS_PROJECT = os.getenv('JENKINS_PROJECT') -else: - JENKINS_PROJECT = SET_JENKINS_PROJECT + if os.getenv('JENKINS_PROJECT'): + JENKINS_PROJECT = os.getenv('JENKINS_PROJECT') + else: + JENKINS_PROJECT = SET_JENKINS_PROJECT -if os.getenv('JENKINS_HOST'): - JENKINS_HOST = os.getenv('JENKINS_HOST') -else: - JENKINS_HOST = SET_JENKINS_HOST + if os.getenv('JENKINS_HOST'): + JENKINS_HOST = os.getenv('JENKINS_HOST') + else: + JENKINS_HOST = SET_JENKINS_HOST -if os.getenv('JENKINS_STAGING_PROJECT'): - JENKINS_STAGING_PROJECT = os.getenv('JENKINS_STAGING_PROJECT') + if os.getenv('JENKINS_STAGING_PROJECT'): + JENKINS_STAGING_PROJECT = os.getenv('JENKINS_STAGING_PROJECT') + else: + JENKINS_STAGING_PROJECT = SET_JENKINS_STAGING_PROJECT else: - JENKINS_STAGING_PROJECT = SET_JENKINS_STAGING_PROJECT - + JENKINS_USER = "" + JENKINS_KEY = "" + JENKINS_TOKEN = "" + JENKINS_PROJECT = "" + JENKINS_HOST = "" + JENKINS_STAGING_PROJECT = "" ## ServiceNOW Integration -if ENV == 'prod': - if os.getenv('SNOW_PASSWORD'): - SNOW_PASSWORD = KeyVaultManager().get_secret(os.getenv('SNOW_PASSWORD')) - else: - SNOW_PASSWORD = KeyVaultManager().get_secret(SET_SNOW_PASSWORD_REF) - if os.getenv('SNOW_CLIENT_SECRET'): - SNOW_CLIENT_SECRET = KeyVaultManager().get_secret(os.getenv('SNOW_CLIENT_SECRET')) - else: - SNOW_CLIENT_SECRET = KeyVaultManager().get_secret(SET_SNOW_CLIENT_SECRET_REF) - if os.getenv('SNOW_INSTANCE_NAME'): - SNOW_INSTANCE_NAME = KeyVaultManager().get_secret(os.getenv('SNOW_INSTANCE_NAME')) - else: - SNOW_INSTANCE_NAME = KeyVaultManager().get_secret(SET_SNOW_INSTANCE_NAME) - if os.getenv('SNOW_CLIENT_ID'): - SNOW_CLIENT_ID = KeyVaultManager().get_secret(os.getenv('SNOW_CLIENT_ID')) - else: - SNOW_CLIENT_ID = KeyVaultManager().get_secret(SET_SNOW_CLIENT_ID) - if os.getenv('SNOW_USERNAME'): - SNOW_USERNAME = KeyVaultManager().get_secret(os.getenv('SNOW_USERNAME')) +if os.getenv('SNOW_ENABLED'): + SNOW_ENABLED = os.getenv('SNOW_ENABLED') +else: + SNOW_ENABLED = SET_SNOW_ENABLED +if SNOW_ENABLED == 'yes': + if ENV == 'prod': + if os.getenv('SNOW_PASSWORD'): + SNOW_PASSWORD = KeyVaultManager().get_secret(os.getenv('SNOW_PASSWORD')) + else: + SNOW_PASSWORD = KeyVaultManager().get_secret(SET_SNOW_PASSWORD_REF) + if os.getenv('SNOW_CLIENT_SECRET'): + SNOW_CLIENT_SECRET = KeyVaultManager().get_secret(os.getenv('SNOW_CLIENT_SECRET')) + else: + SNOW_CLIENT_SECRET = KeyVaultManager().get_secret(SET_SNOW_CLIENT_SECRET_REF) + if os.getenv('SNOW_INSTANCE_NAME'): + SNOW_INSTANCE_NAME = os.getenv('SNOW_INSTANCE_NAME') + else: + SNOW_INSTANCE_NAME = SET_SNOW_INSTANCE_NAME + if os.getenv('SNOW_CLIENT_ID'): + SNOW_CLIENT_ID = os.getenv('SNOW_CLIENT_ID') + else: + SNOW_CLIENT_ID = SET_SNOW_CLIENT_ID + if os.getenv('SNOW_USERNAME'): + SNOW_USERNAME = os.getenv('SNOW_USERNAME') + else: + SNOW_USERNAME = SET_SNOW_USERNAME else: - SNOW_USERNAME = KeyVaultManager().get_secret(SET_SNOW_USERNAME) + SNOW_PASSWORD = SET_SNOW_PASSWORD + SNOW_CLIENT_SECRET = SET_SNOW_CLIENT_SECRET + SNOW_INSTANCE_NAME = SET_SNOW_INSTANCE_NAME + SNOW_CLIENT_ID = SET_SNOW_CLIENT_ID + SNOW_USERNAME = SET_SNOW_USERNAME else: - SNOW_PASSWORD = SET_SNOW_PASSWORD - SNOW_CLIENT_SECRET = SET_SNOW_CLIENT_SECRET - SNOW_INSTANCE_NAME = SET_SNOW_INSTANCE_NAME - SNOW_CLIENT_ID = SET_SNOW_CLIENT_ID - SNOW_USERNAME = SET_SNOW_USERNAME + SNOW_PASSWORD = "" + SNOW_CLIENT_SECRET = "" + SNOW_INSTANCE_NAME = "" + SNOW_CLIENT_ID = "" + SNOW_USERNAME = "" diff --git a/src/settings.py b/src/settings.py index 7273b90b..a893a2f0 100644 --- a/src/settings.py +++ b/src/settings.py @@ -39,6 +39,7 @@ ## ## Jenkins Webhook Settings (Optional) ## +SET_JENKINS_ENABLED = 'no' SET_JENKINS_KEY_REF = 'JENKINS-KEY' SET_JENKINS_USER_REF = 'JENKINS-USER' SET_JENKINS_TOKEN_REF = 'JENKINS-TOKEN' @@ -51,6 +52,7 @@ SET_JENKINS_TOKEN = 'changeme' ## ServiceNOW Settings +SET_SNOW_ENABLED = 'no' SET_SNOW_INSTANCE_NAME = 'dev124268' SET_SNOW_CLIENT_ID = '1ab21bf476013110e1ce39e1f368c2fa' SET_SNOW_CLIENT_SECRET_REF = 'SNOW-SECRET' diff --git a/src/vr/templates/base_auth.html b/src/vr/templates/base_auth.html index 5886557d..df697bc2 100644 --- a/src/vr/templates/base_auth.html +++ b/src/vr/templates/base_auth.html @@ -15,6 +15,7 @@ + From 22a872bdb968b65b6fb45010ac0d0c6fcd30a25e Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 26 Feb 2024 16:44:25 -0800 Subject: [PATCH 018/197] Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins --- Jenkinsfile | 2 ++ src/vr/__init__.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b45f5c3d..dd45e119 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -342,6 +342,8 @@ pipeline { 'secretsSetStrings': stageConfig?.secretsSetStrings, 'serviceCredentials': stageConfig?.serviceCredentials, 'serviceSetStrings': stageConfig?.serviceSetStrings, + 'dockerReg': 'secunicontainerregistry.azurecr.io', + 'imgPullSecret': 'acrCreds' ]) } diff --git a/src/vr/__init__.py b/src/vr/__init__.py index b74f78d5..e1bc03cf 100644 --- a/src/vr/__init__.py +++ b/src/vr/__init__.py @@ -2,7 +2,7 @@ import requests from config_engine import ENV, PROD_DB_URI, AUTH_TYPE, APP_EXT_URL, LDAP_HOST, LDAP_PORT, LDAP_BASE_DN, \ LDAP_USER_DN, LDAP_GROUP_DN, LDAP_USER_RDN_ATTR, LDAP_USER_LOGIN_ATTR, LDAP_BIND_USER_DN, LDAP_BIND_USER_PASSWORD, \ - AZAD_CLIENT_ID, AZAD_CLIENT_SECRET, AZAD_AUTHORITY, JENKINS_USER + AZAD_CLIENT_ID, AZAD_CLIENT_SECRET, AZAD_AUTHORITY, JENKINS_USER, JENKINS_ENABLED from flask import Flask from flask_bootstrap import Bootstrap from flask_login import LoginManager @@ -448,4 +448,5 @@ def get_jenkins_data(): # Call the Jobs Here # train_model_every_six_hours() -get_jenkins_data_every_hour() +if JENKINS_ENABLED == 'yes': + get_jenkins_data_every_hour() From 3579078404975f80b0b7e5082b792daaf95f5a48 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 26 Feb 2024 16:48:20 -0800 Subject: [PATCH 019/197] Release/0.1.0 beta/prod azure (#475) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins --- Jenkinsfile | 4 +++- ci_cd/helm/secusphere/values.yaml | 2 +- pipeline-config.yaml | 8 ++++---- src/vr/__init__.py | 5 +++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d2593530..dd45e119 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -326,7 +326,7 @@ pipeline { // Condition for a Test-* branch expression { // Split the branch name by '/' and check if the last segment starts with 'Test-' - env.BRANCH_NAME.split('/').last().startsWith('staging') + env.BRANCH_NAME.split('/').last().startsWith('staging') || env.BRANCH_NAME.split('/').last().startsWith('Prod') } } } @@ -342,6 +342,8 @@ pipeline { 'secretsSetStrings': stageConfig?.secretsSetStrings, 'serviceCredentials': stageConfig?.serviceCredentials, 'serviceSetStrings': stageConfig?.serviceSetStrings, + 'dockerReg': 'secunicontainerregistry.azurecr.io', + 'imgPullSecret': 'acrCreds' ]) } diff --git a/ci_cd/helm/secusphere/values.yaml b/ci_cd/helm/secusphere/values.yaml index abba5342..8a4fce89 100644 --- a/ci_cd/helm/secusphere/values.yaml +++ b/ci_cd/helm/secusphere/values.yaml @@ -83,7 +83,7 @@ volumes: claimName: su-webapp-pv-claim ingress: - enabled: true + enabled: false serviceAccount: # Specifies whether a service account should be created diff --git a/pipeline-config.yaml b/pipeline-config.yaml index 2267ddc6..daaeead8 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -75,14 +75,14 @@ stages: azure.azTenantId: 'azTenantId' serviceCredentials: {} serviceSetStrings: - app.env: test - app.extUrl: "192.168.0.150" + app.env: prod + app.extUrl: "secusphere.securityuniversal.com" app.db.prodDbUriRef: "PROD-DB-URI" app.smtp.host: "smtp.sendgrid.net:587" app.smtp.user: apikey app.smtp.adminEmail: "admin@securityuniversal.com" - app.smtp.passwordRef: "SENDGRID-SMTP-PW" - app.az.keyVaultName: "BkDevSecOpsKeyVault" + app.smtp.passwordRef: "SMTP-PW" + app.az.keyVaultName: "ss-keyvault" post: enabled: true branches: diff --git a/src/vr/__init__.py b/src/vr/__init__.py index b74f78d5..e1bc03cf 100644 --- a/src/vr/__init__.py +++ b/src/vr/__init__.py @@ -2,7 +2,7 @@ import requests from config_engine import ENV, PROD_DB_URI, AUTH_TYPE, APP_EXT_URL, LDAP_HOST, LDAP_PORT, LDAP_BASE_DN, \ LDAP_USER_DN, LDAP_GROUP_DN, LDAP_USER_RDN_ATTR, LDAP_USER_LOGIN_ATTR, LDAP_BIND_USER_DN, LDAP_BIND_USER_PASSWORD, \ - AZAD_CLIENT_ID, AZAD_CLIENT_SECRET, AZAD_AUTHORITY, JENKINS_USER + AZAD_CLIENT_ID, AZAD_CLIENT_SECRET, AZAD_AUTHORITY, JENKINS_USER, JENKINS_ENABLED from flask import Flask from flask_bootstrap import Bootstrap from flask_login import LoginManager @@ -448,4 +448,5 @@ def get_jenkins_data(): # Call the Jobs Here # train_model_every_six_hours() -get_jenkins_data_every_hour() +if JENKINS_ENABLED == 'yes': + get_jenkins_data_every_hour() From 11694577abc210f1e409b4018451a66a2265c2b0 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 26 Feb 2024 17:18:42 -0800 Subject: [PATCH 020/197] Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile --- Jenkinsfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index dd45e119..52b47457 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -199,7 +199,8 @@ pipeline { jslStageWrapper('Build Docker Service') { script { jslBuildDocker([ - 'serviceName': env.appName + 'serviceName': env.appName, + 'dockerReg': 'secunicontainerregistry.azurecr.io' ]) } } @@ -230,7 +231,7 @@ pipeline { def stageConfig = jslReadYamlConfig('containerScan') def containerName = stageConfig?.containerName def containerTag = stageConfig?.containerTag - jslContainerSecurityScanning(containerName, containerTag) + jslContainerSecurityScanning(containerName, containerTag, 'secunicontainerregistry.azurecr.io') } } } From cc245e482868746e24f4e7d523df71e8ad8db82f Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 26 Feb 2024 17:19:14 -0800 Subject: [PATCH 021/197] Release/0.1.0 beta/prod azure (#477) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile --- Jenkinsfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index dd45e119..52b47457 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -199,7 +199,8 @@ pipeline { jslStageWrapper('Build Docker Service') { script { jslBuildDocker([ - 'serviceName': env.appName + 'serviceName': env.appName, + 'dockerReg': 'secunicontainerregistry.azurecr.io' ]) } } @@ -230,7 +231,7 @@ pipeline { def stageConfig = jslReadYamlConfig('containerScan') def containerName = stageConfig?.containerName def containerTag = stageConfig?.containerTag - jslContainerSecurityScanning(containerName, containerTag) + jslContainerSecurityScanning(containerName, containerTag, 'secunicontainerregistry.azurecr.io') } } } From 4b6af0b1b7d45088ba5add56aeb392a83ec7ccdb Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 27 Feb 2024 20:22:24 -0800 Subject: [PATCH 022/197] Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml From 4f661bda918f5f87fa15062d7283bef491d2013e Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 27 Feb 2024 20:22:54 -0800 Subject: [PATCH 023/197] Release/0.1.0 beta/prod azure (#479) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml From cebffc6cb0dbc6f5a7ac0190cef8756506297c0b Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 27 Feb 2024 20:29:25 -0800 Subject: [PATCH 024/197] Update pipeline-config.yaml --- pipeline-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline-config.yaml b/pipeline-config.yaml index daaeead8..55659e84 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -56,7 +56,7 @@ stages: dastTestType: full apiTargetUrl: 'http://192.168.0.68:5010/api/openapi.yaml' securityQualityGate: - enabled: false + enabled: true branches: - release deploy: From 8e01ce66cbaa0da69af90f118eb7fd61d3ff2714 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 27 Feb 2024 20:29:57 -0800 Subject: [PATCH 025/197] Release/0.1.0 beta/prod azure (#480) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml --- pipeline-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline-config.yaml b/pipeline-config.yaml index daaeead8..55659e84 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -56,7 +56,7 @@ stages: dastTestType: full apiTargetUrl: 'http://192.168.0.68:5010/api/openapi.yaml' securityQualityGate: - enabled: false + enabled: true branches: - release deploy: From 38282ba86ef3bb91e0134a1b413c7deaf08864b0 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 27 Feb 2024 20:56:02 -0800 Subject: [PATCH 026/197] Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile --- Jenkinsfile | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 52b47457..281ac45d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -75,7 +75,7 @@ pipeline { stage('Secret Scanning') { agent { docker { - image 'securityuniversal/jenkins-secret-agent:latest' + image 'securityuniversal/jenkins-sectesting-agent:latest' } } when { @@ -99,7 +99,7 @@ pipeline { stage('Software Composition Analysis') { agent { docker { - image 'securityuniversal/jenkins:latest' + image 'securityuniversal/jenkins-sectesting-agent:latest' } } when { @@ -127,7 +127,7 @@ pipeline { stage('Static Application Security Testing') { agent { docker { - image 'securityuniversal/jenkins:latest' + image 'securityuniversal/jenkins-sectesting-agent:latest' } } when { @@ -155,7 +155,7 @@ pipeline { stage('Infrastructure-as-Code Security Testing') { agent { docker { - image 'securityuniversal/jenkins-iac-agent:latest' + image 'securityuniversal/jenkins-sectesting-agent:latest' args '--group-add 999' } } @@ -210,7 +210,7 @@ pipeline { stage('Docker Container Scanning') { agent { docker { - image 'securityuniversal/jenkins-iac-agent:latest' + image 'securityuniversal/jenkins-sectesting-agent:latest' args '--group-add 999' } } @@ -294,6 +294,12 @@ pipeline { ////////// Quality Gate ////////// stage("Quality Gate - Security") { + agent { + docker { + image 'securityuniversal/jenkins-sectesting-agent:latest' + args '--group-add 999' + } + } when { expression { def config = jslReadYamlConfig('securityQualityGate') From 4b3ba1f8fa8b2272dce8652855a48dd0347b85b9 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 27 Feb 2024 20:56:30 -0800 Subject: [PATCH 027/197] Release/0.1.0 beta/prod azure (#482) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile --- Jenkinsfile | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 52b47457..281ac45d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -75,7 +75,7 @@ pipeline { stage('Secret Scanning') { agent { docker { - image 'securityuniversal/jenkins-secret-agent:latest' + image 'securityuniversal/jenkins-sectesting-agent:latest' } } when { @@ -99,7 +99,7 @@ pipeline { stage('Software Composition Analysis') { agent { docker { - image 'securityuniversal/jenkins:latest' + image 'securityuniversal/jenkins-sectesting-agent:latest' } } when { @@ -127,7 +127,7 @@ pipeline { stage('Static Application Security Testing') { agent { docker { - image 'securityuniversal/jenkins:latest' + image 'securityuniversal/jenkins-sectesting-agent:latest' } } when { @@ -155,7 +155,7 @@ pipeline { stage('Infrastructure-as-Code Security Testing') { agent { docker { - image 'securityuniversal/jenkins-iac-agent:latest' + image 'securityuniversal/jenkins-sectesting-agent:latest' args '--group-add 999' } } @@ -210,7 +210,7 @@ pipeline { stage('Docker Container Scanning') { agent { docker { - image 'securityuniversal/jenkins-iac-agent:latest' + image 'securityuniversal/jenkins-sectesting-agent:latest' args '--group-add 999' } } @@ -294,6 +294,12 @@ pipeline { ////////// Quality Gate ////////// stage("Quality Gate - Security") { + agent { + docker { + image 'securityuniversal/jenkins-sectesting-agent:latest' + args '--group-add 999' + } + } when { expression { def config = jslReadYamlConfig('securityQualityGate') From 86da6a05ae9223d44dfc649d04c15c85b8599590 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 27 Feb 2024 22:07:02 -0800 Subject: [PATCH 028/197] Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing --- Jenkinsfile | 2 +- pipeline-config.yaml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 281ac45d..a2d43df6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,7 +51,7 @@ pipeline { stage('Unit Testing') { agent { docker { - image 'securityuniversal/jenkins:latest' + image 'securityuniversal/jenkins-python-agent:latest' } } when { diff --git a/pipeline-config.yaml b/pipeline-config.yaml index 55659e84..93ec1421 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -9,21 +9,21 @@ stages: branches: - release unitTesting: - enabled: false + enabled: true branches: [] secretScanning: enabled: true branches: - release sca: - enabled: false + enabled: true branches: - release codeLanguages: - Python - Javascript sast: - enabled: false + enabled: true branches: - release codeLanguages: @@ -37,19 +37,19 @@ stages: branches: - release containerScan: - enabled: false + enabled: true branches: - release containerName: secusphere containerTag: latest releaseToTest: - enabled: false + enabled: true branches: - release serviceName: secusphere containerTag: latest testRelease: - enabled: false + enabled: true branches: - release targetUrl: 'http://192.168.0.68:5010' From df33d2f84b39fce0ca3f37060628378895d8d1fb Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 27 Feb 2024 22:07:27 -0800 Subject: [PATCH 029/197] Release/0.1.0 beta/prod azure (#484) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing --- Jenkinsfile | 2 +- pipeline-config.yaml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 281ac45d..a2d43df6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,7 +51,7 @@ pipeline { stage('Unit Testing') { agent { docker { - image 'securityuniversal/jenkins:latest' + image 'securityuniversal/jenkins-python-agent:latest' } } when { diff --git a/pipeline-config.yaml b/pipeline-config.yaml index 55659e84..93ec1421 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -9,21 +9,21 @@ stages: branches: - release unitTesting: - enabled: false + enabled: true branches: [] secretScanning: enabled: true branches: - release sca: - enabled: false + enabled: true branches: - release codeLanguages: - Python - Javascript sast: - enabled: false + enabled: true branches: - release codeLanguages: @@ -37,19 +37,19 @@ stages: branches: - release containerScan: - enabled: false + enabled: true branches: - release containerName: secusphere containerTag: latest releaseToTest: - enabled: false + enabled: true branches: - release serviceName: secusphere containerTag: latest testRelease: - enabled: false + enabled: true branches: - release targetUrl: 'http://192.168.0.68:5010' From e019adeac8a7cd178f3b587652f3cc96a82dc81a Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sat, 9 Mar 2024 11:32:31 -0800 Subject: [PATCH 030/197] Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py --- src/vr/api/vulns/vulnerabilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vr/api/vulns/vulnerabilities.py b/src/vr/api/vulns/vulnerabilities.py index 7f0c000e..68360c8b 100644 --- a/src/vr/api/vulns/vulnerabilities.py +++ b/src/vr/api/vulns/vulnerabilities.py @@ -132,7 +132,7 @@ def update_vulnerabilities_status(app_cmdb_id, scan_id, req_raw): def add_vulns_background_process(req_raw): now = datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") app_name = req_raw['appName'] - git_url = req_raw['giturl'] + git_url = req_raw['gitUrl'] git_branch = req_raw['branch'] findings = req_raw['findings'] scan_type = req_raw['scanType'] From 53a54743dd8726742029cdcd9ef506347564c815 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sat, 9 Mar 2024 11:33:36 -0800 Subject: [PATCH 031/197] Release/0.1.0 beta/prod azure (#486) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py --- src/vr/api/vulns/vulnerabilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vr/api/vulns/vulnerabilities.py b/src/vr/api/vulns/vulnerabilities.py index 7f0c000e..68360c8b 100644 --- a/src/vr/api/vulns/vulnerabilities.py +++ b/src/vr/api/vulns/vulnerabilities.py @@ -132,7 +132,7 @@ def update_vulnerabilities_status(app_cmdb_id, scan_id, req_raw): def add_vulns_background_process(req_raw): now = datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") app_name = req_raw['appName'] - git_url = req_raw['giturl'] + git_url = req_raw['gitUrl'] git_branch = req_raw['branch'] findings = req_raw['findings'] scan_type = req_raw['scanType'] From 33e0b20eb87cf03926567167c608ed6dd6956960 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sat, 9 Mar 2024 13:57:17 -0800 Subject: [PATCH 032/197] Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml --- pipeline-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pipeline-config.yaml b/pipeline-config.yaml index 93ec1421..60ce6fce 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -12,7 +12,7 @@ stages: enabled: true branches: [] secretScanning: - enabled: true + enabled: false branches: - release sca: @@ -29,7 +29,7 @@ stages: codeLanguages: - Python iac: - enabled: true + enabled: false branches: - release buildDocker: From 405448ac6954b0ca23e943fcaa2231294d203af7 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sat, 9 Mar 2024 13:57:39 -0800 Subject: [PATCH 033/197] Release/0.1.0 beta/prod azure (#488) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml --- pipeline-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pipeline-config.yaml b/pipeline-config.yaml index 93ec1421..60ce6fce 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -12,7 +12,7 @@ stages: enabled: true branches: [] secretScanning: - enabled: true + enabled: false branches: - release sca: @@ -29,7 +29,7 @@ stages: codeLanguages: - Python iac: - enabled: true + enabled: false branches: - release buildDocker: From 509a6f102f692e5756090d5e76cb8bbefb64d606 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sat, 9 Mar 2024 14:41:24 -0800 Subject: [PATCH 034/197] Update pipeline-config.yaml --- pipeline-config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pipeline-config.yaml b/pipeline-config.yaml index 60ce6fce..2a9eb073 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -9,21 +9,21 @@ stages: branches: - release unitTesting: - enabled: true + enabled: false branches: [] secretScanning: enabled: false branches: - release sca: - enabled: true + enabled: false branches: - release codeLanguages: - Python - Javascript sast: - enabled: true + enabled: false branches: - release codeLanguages: @@ -37,26 +37,26 @@ stages: branches: - release containerScan: - enabled: true + enabled: false branches: - release containerName: secusphere containerTag: latest releaseToTest: - enabled: true + enabled: false branches: - release serviceName: secusphere containerTag: latest testRelease: - enabled: true + enabled: false branches: - release targetUrl: 'http://192.168.0.68:5010' dastTestType: full apiTargetUrl: 'http://192.168.0.68:5010/api/openapi.yaml' securityQualityGate: - enabled: true + enabled: false branches: - release deploy: From e819b231b1735330996a2140f0241a0d16c98745 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sat, 9 Mar 2024 14:41:59 -0800 Subject: [PATCH 035/197] Release/0.1.0 beta/prod azure (#489) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml From a52196c87a15f99d3970b7c5ea93adb8bbe09eba Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sat, 9 Mar 2024 15:29:24 -0800 Subject: [PATCH 036/197] Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile --- Jenkinsfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a2d43df6..8f818749 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -348,9 +348,7 @@ pipeline { 'secretsCredentials': stageConfig?.secretsCredentials, 'secretsSetStrings': stageConfig?.secretsSetStrings, 'serviceCredentials': stageConfig?.serviceCredentials, - 'serviceSetStrings': stageConfig?.serviceSetStrings, - 'dockerReg': 'secunicontainerregistry.azurecr.io', - 'imgPullSecret': 'acrCreds' + 'serviceSetStrings': stageConfig?.serviceSetStrings ]) } From 6273f97f5fc8ff0ac187ff4e307567e29d4eeca2 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sat, 9 Mar 2024 15:30:23 -0800 Subject: [PATCH 037/197] Release/0.1.0 beta/prod azure (#491) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile --- Jenkinsfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a2d43df6..8f818749 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -348,9 +348,7 @@ pipeline { 'secretsCredentials': stageConfig?.secretsCredentials, 'secretsSetStrings': stageConfig?.secretsSetStrings, 'serviceCredentials': stageConfig?.serviceCredentials, - 'serviceSetStrings': stageConfig?.serviceSetStrings, - 'dockerReg': 'secunicontainerregistry.azurecr.io', - 'imgPullSecret': 'acrCreds' + 'serviceSetStrings': stageConfig?.serviceSetStrings ]) } From 0f392046bbbd480c0b7936825fd51cb76cf7c4ee Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sat, 9 Mar 2024 15:37:20 -0800 Subject: [PATCH 038/197] Update pipeline-config.yaml --- pipeline-config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pipeline-config.yaml b/pipeline-config.yaml index 60ce6fce..2a9eb073 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -9,21 +9,21 @@ stages: branches: - release unitTesting: - enabled: true + enabled: false branches: [] secretScanning: enabled: false branches: - release sca: - enabled: true + enabled: false branches: - release codeLanguages: - Python - Javascript sast: - enabled: true + enabled: false branches: - release codeLanguages: @@ -37,26 +37,26 @@ stages: branches: - release containerScan: - enabled: true + enabled: false branches: - release containerName: secusphere containerTag: latest releaseToTest: - enabled: true + enabled: false branches: - release serviceName: secusphere containerTag: latest testRelease: - enabled: true + enabled: false branches: - release targetUrl: 'http://192.168.0.68:5010' dastTestType: full apiTargetUrl: 'http://192.168.0.68:5010/api/openapi.yaml' securityQualityGate: - enabled: true + enabled: false branches: - release deploy: From 140ad448c9d97ef7c1ebf84368163d7086386f0b Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sat, 9 Mar 2024 15:41:14 -0800 Subject: [PATCH 039/197] Release/0.1.0 beta/prod azure (#492) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml --- pipeline-config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pipeline-config.yaml b/pipeline-config.yaml index 60ce6fce..2a9eb073 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -9,21 +9,21 @@ stages: branches: - release unitTesting: - enabled: true + enabled: false branches: [] secretScanning: enabled: false branches: - release sca: - enabled: true + enabled: false branches: - release codeLanguages: - Python - Javascript sast: - enabled: true + enabled: false branches: - release codeLanguages: @@ -37,26 +37,26 @@ stages: branches: - release containerScan: - enabled: true + enabled: false branches: - release containerName: secusphere containerTag: latest releaseToTest: - enabled: true + enabled: false branches: - release serviceName: secusphere containerTag: latest testRelease: - enabled: true + enabled: false branches: - release targetUrl: 'http://192.168.0.68:5010' dastTestType: full apiTargetUrl: 'http://192.168.0.68:5010/api/openapi.yaml' securityQualityGate: - enabled: true + enabled: false branches: - release deploy: From ce79251e3f30ecfd7c3d00b5469ef4b7fbd64b5a Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sat, 9 Mar 2024 16:00:28 -0800 Subject: [PATCH 040/197] Update Jenkinsfile (#493) --- Jenkinsfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8f818749..bac83770 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -199,8 +199,7 @@ pipeline { jslStageWrapper('Build Docker Service') { script { jslBuildDocker([ - 'serviceName': env.appName, - 'dockerReg': 'secunicontainerregistry.azurecr.io' + 'serviceName': env.appName ]) } } @@ -231,7 +230,7 @@ pipeline { def stageConfig = jslReadYamlConfig('containerScan') def containerName = stageConfig?.containerName def containerTag = stageConfig?.containerTag - jslContainerSecurityScanning(containerName, containerTag, 'secunicontainerregistry.azurecr.io') + jslContainerSecurityScanning(containerName, containerTag) } } } From 7c2828ffa3aae746b054b661ac5ce5ddca51170b Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sat, 9 Mar 2024 16:00:58 -0800 Subject: [PATCH 041/197] Release/0.1.0 beta/prod azure (#494) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) --- Jenkinsfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8f818749..bac83770 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -199,8 +199,7 @@ pipeline { jslStageWrapper('Build Docker Service') { script { jslBuildDocker([ - 'serviceName': env.appName, - 'dockerReg': 'secunicontainerregistry.azurecr.io' + 'serviceName': env.appName ]) } } @@ -231,7 +230,7 @@ pipeline { def stageConfig = jslReadYamlConfig('containerScan') def containerName = stageConfig?.containerName def containerTag = stageConfig?.containerTag - jslContainerSecurityScanning(containerName, containerTag, 'secunicontainerregistry.azurecr.io') + jslContainerSecurityScanning(containerName, containerTag) } } } From 5fdd5b1eac66709c5fba401da314f608c1c67d21 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 12 Mar 2024 18:45:36 -0700 Subject: [PATCH 042/197] Update security_quality_gate.py --- src/vr/api/vulns/security_quality_gate.py | 128 +++++++++++----------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/src/vr/api/vulns/security_quality_gate.py b/src/vr/api/vulns/security_quality_gate.py index 930c2a1b..b00c1b1e 100644 --- a/src/vr/api/vulns/security_quality_gate.py +++ b/src/vr/api/vulns/security_quality_gate.py @@ -51,38 +51,38 @@ def _add_sg_config_settings(config, job_id, app_id): job = SgConfigSettingsPerJob( AppID=app_id, PipelineJobID = job_id, - ThreshScaLow = config['thresholds']['sca']['low'], - ThreshScaMedium = config['thresholds']['sca']['medium'], - ThreshScaHigh = config['thresholds']['sca']['high'], - ThreshScaCritical = config['thresholds']['sca']['critical'], - ThreshContainerLow = config['thresholds']['container']['low'], - ThreshContainerMedium = config['thresholds']['container']['medium'], - ThreshContainerHigh = config['thresholds']['container']['high'], - ThreshContainerCritical = config['thresholds']['container']['critical'], - ThreshDastLow = config['thresholds']['dast']['low'], - ThreshDastMedium = config['thresholds']['dast']['medium'], - ThreshDastHigh = config['thresholds']['dast']['high'], - ThreshDastCritical = config['thresholds']['dast']['critical'], - ThreshDastApiLow = config['thresholds']['dastapi']['low'], - ThreshDastApiMedium = config['thresholds']['dastapi']['medium'], - ThreshDastApiHigh = config['thresholds']['dastapi']['high'], - ThreshDastApiCritical = config['thresholds']['dastapi']['critical'], - ThreshInfrastructureLow = config['thresholds']['infrastructure']['low'], - ThreshInfrastructureMedium = config['thresholds']['infrastructure']['medium'], - ThreshInfrastructureHigh = config['thresholds']['infrastructure']['high'], - ThreshInfrastructureCritical = config['thresholds']['infrastructure']['critical'], - ThreshSastLow = config['thresholds']['sast']['low'], - ThreshSastMedium = config['thresholds']['sast']['medium'], - ThreshSastHigh = config['thresholds']['sast']['high'], - ThreshSastCritical = config['thresholds']['sast']['critical'], - ThreshIacLow = config['thresholds']['iac']['low'], - ThreshIacMedium = config['thresholds']['iac']['medium'], - ThreshIacHigh = config['thresholds']['iac']['high'], - ThreshIacCritical = config['thresholds']['iac']['critical'], - ThreshSecretsLow = config['thresholds']['secret']['low'], - ThreshSecretsMedium = config['thresholds']['secret']['medium'], - ThreshSecretsHigh = config['thresholds']['secret']['high'], - ThreshSecretsCritical = config['thresholds']['secret']['critical'], + ThreshScaLow = config['sca']['low'], + ThreshScaMedium = config['sca']['medium'], + ThreshScaHigh = config['sca']['high'], + ThreshScaCritical = config['sca']['critical'], + ThreshContainerLow = config['container']['low'], + ThreshContainerMedium = config['container']['medium'], + ThreshContainerHigh = config['container']['high'], + ThreshContainerCritical = config['container']['critical'], + ThreshDastLow = config['dast']['low'], + ThreshDastMedium = config['dast']['medium'], + ThreshDastHigh = config['dast']['high'], + ThreshDastCritical = config['dast']['critical'], + ThreshDastApiLow = config['dastapi']['low'], + ThreshDastApiMedium = config['dastapi']['medium'], + ThreshDastApiHigh = config['dastapi']['high'], + ThreshDastApiCritical = config['dastapi']['critical'], + ThreshInfrastructureLow = config['infrastructure']['low'], + ThreshInfrastructureMedium = config['infrastructure']['medium'], + ThreshInfrastructureHigh = config['infrastructure']['high'], + ThreshInfrastructureCritical = config['infrastructure']['critical'], + ThreshSastLow = config['sast']['low'], + ThreshSastMedium = config['sast']['medium'], + ThreshSastHigh = config['sast']['high'], + ThreshSastCritical = config['sast']['critical'], + ThreshIacLow = config['iac']['low'], + ThreshIacMedium = config['iac']['medium'], + ThreshIacHigh = config['iac']['high'], + ThreshIacCritical = config['iac']['critical'], + ThreshSecretsLow = config['secret']['low'], + ThreshSecretsMedium = config['secret']['medium'], + ThreshSecretsHigh = config['secret']['high'], + ThreshSecretsCritical = config['secret']['critical'], ) db.session.add(job) db_connection_handler(db) @@ -92,38 +92,38 @@ def _add_sg_results(results, job_id, app_id): job = SgResultsPerJob( AppID=app_id, PipelineJobID=job_id, - ResultScaLow=results['report']['sca']['low'], - ResultScaMedium=results['report']['sca']['medium'], - ResultScaHigh=results['report']['sca']['high'], - ResultScaCritical=results['report']['sca']['critical'], - ResultContainerLow=results['report']['container']['low'], - ResultContainerMedium=results['report']['container']['medium'], - ResultContainerHigh=results['report']['container']['high'], - ResultContainerCritical=results['report']['container']['critical'], - ResultDastLow=results['report']['dast']['low'], - ResultDastMedium=results['report']['dast']['medium'], - ResultDastHigh=results['report']['dast']['high'], - ResultDastCritical=results['report']['dast']['critical'], - ResultDastApiLow=results['report']['dastapi']['low'], - ResultDastApiMedium=results['report']['dastapi']['medium'], - ResultDastApiHigh=results['report']['dastapi']['high'], - ResultDastApiCritical=results['report']['dastapi']['critical'], - ResultInfrastructureLow=results['report']['infrastructure']['low'], - ResultInfrastructureMedium=results['report']['infrastructure']['medium'], - ResultInfrastructureHigh=results['report']['infrastructure']['high'], - ResultInfrastructureCritical=results['report']['infrastructure']['critical'], - ResultSastLow=results['report']['sast']['low'], - ResultSastMedium=results['report']['sast']['medium'], - ResultSastHigh=results['report']['sast']['high'], - ResultSastCritical=results['report']['sast']['critical'], - ResultIacLow=results['report']['iac']['low'], - ResultIacMedium=results['report']['iac']['medium'], - ResultIacHigh=results['report']['iac']['high'], - ResultIacCritical=results['report']['iac']['critical'], - ResultSecretsLow=results['report']['secret']['low'], - ResultSecretsMedium=results['report']['secret']['medium'], - ResultSecretsHigh=results['report']['secret']['high'], - ResultSecretsCritical=results['report']['secret']['critical'], + ResultScaLow=results['sca']['low'], + ResultScaMedium=results['sca']['medium'], + ResultScaHigh=results['sca']['high'], + ResultScaCritical=results['sca']['critical'], + ResultContainerLow=results['container']['low'], + ResultContainerMedium=results['container']['medium'], + ResultContainerHigh=results['container']['high'], + ResultContainerCritical=results['container']['critical'], + ResultDastLow=results['dast']['low'], + ResultDastMedium=results['dast']['medium'], + ResultDastHigh=results['dast']['high'], + ResultDastCritical=results['dast']['critical'], + ResultDastApiLow=results['dastapi']['low'], + ResultDastApiMedium=results['dastapi']['medium'], + ResultDastApiHigh=results['dastapi']['high'], + ResultDastApiCritical=results['dastapi']['critical'], + ResultInfrastructureLow=results['infrastructure']['low'], + ResultInfrastructureMedium=results['infrastructure']['medium'], + ResultInfrastructureHigh=results['infrastructure']['high'], + ResultInfrastructureCritical=results['infrastructure']['critical'], + ResultSastLow=results['sast']['low'], + ResultSastMedium=results['sast']['medium'], + ResultSastHigh=results['sast']['high'], + ResultSastCritical=results['sast']['critical'], + ResultIacLow=results['iac']['low'], + ResultIacMedium=results['iac']['medium'], + ResultIacHigh=results['iac']['high'], + ResultIacCritical=results['iac']['critical'], + ResultSecretsLow=results['secret']['low'], + ResultSecretsMedium=results['secret']['medium'], + ResultSecretsHigh=results['secret']['high'], + ResultSecretsCritical=results['secret']['critical'], ) db.session.add(job) db_connection_handler(db) From 686ae51cac2c97ecaa9ee15b58d9cf7e43d82a76 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 12 Mar 2024 18:51:17 -0700 Subject: [PATCH 043/197] Update security_quality_gate.py (#495) --- src/vr/api/vulns/security_quality_gate.py | 128 +++++++++++----------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/src/vr/api/vulns/security_quality_gate.py b/src/vr/api/vulns/security_quality_gate.py index 930c2a1b..b00c1b1e 100644 --- a/src/vr/api/vulns/security_quality_gate.py +++ b/src/vr/api/vulns/security_quality_gate.py @@ -51,38 +51,38 @@ def _add_sg_config_settings(config, job_id, app_id): job = SgConfigSettingsPerJob( AppID=app_id, PipelineJobID = job_id, - ThreshScaLow = config['thresholds']['sca']['low'], - ThreshScaMedium = config['thresholds']['sca']['medium'], - ThreshScaHigh = config['thresholds']['sca']['high'], - ThreshScaCritical = config['thresholds']['sca']['critical'], - ThreshContainerLow = config['thresholds']['container']['low'], - ThreshContainerMedium = config['thresholds']['container']['medium'], - ThreshContainerHigh = config['thresholds']['container']['high'], - ThreshContainerCritical = config['thresholds']['container']['critical'], - ThreshDastLow = config['thresholds']['dast']['low'], - ThreshDastMedium = config['thresholds']['dast']['medium'], - ThreshDastHigh = config['thresholds']['dast']['high'], - ThreshDastCritical = config['thresholds']['dast']['critical'], - ThreshDastApiLow = config['thresholds']['dastapi']['low'], - ThreshDastApiMedium = config['thresholds']['dastapi']['medium'], - ThreshDastApiHigh = config['thresholds']['dastapi']['high'], - ThreshDastApiCritical = config['thresholds']['dastapi']['critical'], - ThreshInfrastructureLow = config['thresholds']['infrastructure']['low'], - ThreshInfrastructureMedium = config['thresholds']['infrastructure']['medium'], - ThreshInfrastructureHigh = config['thresholds']['infrastructure']['high'], - ThreshInfrastructureCritical = config['thresholds']['infrastructure']['critical'], - ThreshSastLow = config['thresholds']['sast']['low'], - ThreshSastMedium = config['thresholds']['sast']['medium'], - ThreshSastHigh = config['thresholds']['sast']['high'], - ThreshSastCritical = config['thresholds']['sast']['critical'], - ThreshIacLow = config['thresholds']['iac']['low'], - ThreshIacMedium = config['thresholds']['iac']['medium'], - ThreshIacHigh = config['thresholds']['iac']['high'], - ThreshIacCritical = config['thresholds']['iac']['critical'], - ThreshSecretsLow = config['thresholds']['secret']['low'], - ThreshSecretsMedium = config['thresholds']['secret']['medium'], - ThreshSecretsHigh = config['thresholds']['secret']['high'], - ThreshSecretsCritical = config['thresholds']['secret']['critical'], + ThreshScaLow = config['sca']['low'], + ThreshScaMedium = config['sca']['medium'], + ThreshScaHigh = config['sca']['high'], + ThreshScaCritical = config['sca']['critical'], + ThreshContainerLow = config['container']['low'], + ThreshContainerMedium = config['container']['medium'], + ThreshContainerHigh = config['container']['high'], + ThreshContainerCritical = config['container']['critical'], + ThreshDastLow = config['dast']['low'], + ThreshDastMedium = config['dast']['medium'], + ThreshDastHigh = config['dast']['high'], + ThreshDastCritical = config['dast']['critical'], + ThreshDastApiLow = config['dastapi']['low'], + ThreshDastApiMedium = config['dastapi']['medium'], + ThreshDastApiHigh = config['dastapi']['high'], + ThreshDastApiCritical = config['dastapi']['critical'], + ThreshInfrastructureLow = config['infrastructure']['low'], + ThreshInfrastructureMedium = config['infrastructure']['medium'], + ThreshInfrastructureHigh = config['infrastructure']['high'], + ThreshInfrastructureCritical = config['infrastructure']['critical'], + ThreshSastLow = config['sast']['low'], + ThreshSastMedium = config['sast']['medium'], + ThreshSastHigh = config['sast']['high'], + ThreshSastCritical = config['sast']['critical'], + ThreshIacLow = config['iac']['low'], + ThreshIacMedium = config['iac']['medium'], + ThreshIacHigh = config['iac']['high'], + ThreshIacCritical = config['iac']['critical'], + ThreshSecretsLow = config['secret']['low'], + ThreshSecretsMedium = config['secret']['medium'], + ThreshSecretsHigh = config['secret']['high'], + ThreshSecretsCritical = config['secret']['critical'], ) db.session.add(job) db_connection_handler(db) @@ -92,38 +92,38 @@ def _add_sg_results(results, job_id, app_id): job = SgResultsPerJob( AppID=app_id, PipelineJobID=job_id, - ResultScaLow=results['report']['sca']['low'], - ResultScaMedium=results['report']['sca']['medium'], - ResultScaHigh=results['report']['sca']['high'], - ResultScaCritical=results['report']['sca']['critical'], - ResultContainerLow=results['report']['container']['low'], - ResultContainerMedium=results['report']['container']['medium'], - ResultContainerHigh=results['report']['container']['high'], - ResultContainerCritical=results['report']['container']['critical'], - ResultDastLow=results['report']['dast']['low'], - ResultDastMedium=results['report']['dast']['medium'], - ResultDastHigh=results['report']['dast']['high'], - ResultDastCritical=results['report']['dast']['critical'], - ResultDastApiLow=results['report']['dastapi']['low'], - ResultDastApiMedium=results['report']['dastapi']['medium'], - ResultDastApiHigh=results['report']['dastapi']['high'], - ResultDastApiCritical=results['report']['dastapi']['critical'], - ResultInfrastructureLow=results['report']['infrastructure']['low'], - ResultInfrastructureMedium=results['report']['infrastructure']['medium'], - ResultInfrastructureHigh=results['report']['infrastructure']['high'], - ResultInfrastructureCritical=results['report']['infrastructure']['critical'], - ResultSastLow=results['report']['sast']['low'], - ResultSastMedium=results['report']['sast']['medium'], - ResultSastHigh=results['report']['sast']['high'], - ResultSastCritical=results['report']['sast']['critical'], - ResultIacLow=results['report']['iac']['low'], - ResultIacMedium=results['report']['iac']['medium'], - ResultIacHigh=results['report']['iac']['high'], - ResultIacCritical=results['report']['iac']['critical'], - ResultSecretsLow=results['report']['secret']['low'], - ResultSecretsMedium=results['report']['secret']['medium'], - ResultSecretsHigh=results['report']['secret']['high'], - ResultSecretsCritical=results['report']['secret']['critical'], + ResultScaLow=results['sca']['low'], + ResultScaMedium=results['sca']['medium'], + ResultScaHigh=results['sca']['high'], + ResultScaCritical=results['sca']['critical'], + ResultContainerLow=results['container']['low'], + ResultContainerMedium=results['container']['medium'], + ResultContainerHigh=results['container']['high'], + ResultContainerCritical=results['container']['critical'], + ResultDastLow=results['dast']['low'], + ResultDastMedium=results['dast']['medium'], + ResultDastHigh=results['dast']['high'], + ResultDastCritical=results['dast']['critical'], + ResultDastApiLow=results['dastapi']['low'], + ResultDastApiMedium=results['dastapi']['medium'], + ResultDastApiHigh=results['dastapi']['high'], + ResultDastApiCritical=results['dastapi']['critical'], + ResultInfrastructureLow=results['infrastructure']['low'], + ResultInfrastructureMedium=results['infrastructure']['medium'], + ResultInfrastructureHigh=results['infrastructure']['high'], + ResultInfrastructureCritical=results['infrastructure']['critical'], + ResultSastLow=results['sast']['low'], + ResultSastMedium=results['sast']['medium'], + ResultSastHigh=results['sast']['high'], + ResultSastCritical=results['sast']['critical'], + ResultIacLow=results['iac']['low'], + ResultIacMedium=results['iac']['medium'], + ResultIacHigh=results['iac']['high'], + ResultIacCritical=results['iac']['critical'], + ResultSecretsLow=results['secret']['low'], + ResultSecretsMedium=results['secret']['medium'], + ResultSecretsHigh=results['secret']['high'], + ResultSecretsCritical=results['secret']['critical'], ) db.session.add(job) db_connection_handler(db) From 99609d73b9a7b48fa69de8101d914ef1c3ce56c1 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 12 Mar 2024 18:51:44 -0700 Subject: [PATCH 044/197] Release/0.1.0 beta/prod azure (#496) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) --- src/vr/api/vulns/security_quality_gate.py | 128 +++++++++++----------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/src/vr/api/vulns/security_quality_gate.py b/src/vr/api/vulns/security_quality_gate.py index 930c2a1b..b00c1b1e 100644 --- a/src/vr/api/vulns/security_quality_gate.py +++ b/src/vr/api/vulns/security_quality_gate.py @@ -51,38 +51,38 @@ def _add_sg_config_settings(config, job_id, app_id): job = SgConfigSettingsPerJob( AppID=app_id, PipelineJobID = job_id, - ThreshScaLow = config['thresholds']['sca']['low'], - ThreshScaMedium = config['thresholds']['sca']['medium'], - ThreshScaHigh = config['thresholds']['sca']['high'], - ThreshScaCritical = config['thresholds']['sca']['critical'], - ThreshContainerLow = config['thresholds']['container']['low'], - ThreshContainerMedium = config['thresholds']['container']['medium'], - ThreshContainerHigh = config['thresholds']['container']['high'], - ThreshContainerCritical = config['thresholds']['container']['critical'], - ThreshDastLow = config['thresholds']['dast']['low'], - ThreshDastMedium = config['thresholds']['dast']['medium'], - ThreshDastHigh = config['thresholds']['dast']['high'], - ThreshDastCritical = config['thresholds']['dast']['critical'], - ThreshDastApiLow = config['thresholds']['dastapi']['low'], - ThreshDastApiMedium = config['thresholds']['dastapi']['medium'], - ThreshDastApiHigh = config['thresholds']['dastapi']['high'], - ThreshDastApiCritical = config['thresholds']['dastapi']['critical'], - ThreshInfrastructureLow = config['thresholds']['infrastructure']['low'], - ThreshInfrastructureMedium = config['thresholds']['infrastructure']['medium'], - ThreshInfrastructureHigh = config['thresholds']['infrastructure']['high'], - ThreshInfrastructureCritical = config['thresholds']['infrastructure']['critical'], - ThreshSastLow = config['thresholds']['sast']['low'], - ThreshSastMedium = config['thresholds']['sast']['medium'], - ThreshSastHigh = config['thresholds']['sast']['high'], - ThreshSastCritical = config['thresholds']['sast']['critical'], - ThreshIacLow = config['thresholds']['iac']['low'], - ThreshIacMedium = config['thresholds']['iac']['medium'], - ThreshIacHigh = config['thresholds']['iac']['high'], - ThreshIacCritical = config['thresholds']['iac']['critical'], - ThreshSecretsLow = config['thresholds']['secret']['low'], - ThreshSecretsMedium = config['thresholds']['secret']['medium'], - ThreshSecretsHigh = config['thresholds']['secret']['high'], - ThreshSecretsCritical = config['thresholds']['secret']['critical'], + ThreshScaLow = config['sca']['low'], + ThreshScaMedium = config['sca']['medium'], + ThreshScaHigh = config['sca']['high'], + ThreshScaCritical = config['sca']['critical'], + ThreshContainerLow = config['container']['low'], + ThreshContainerMedium = config['container']['medium'], + ThreshContainerHigh = config['container']['high'], + ThreshContainerCritical = config['container']['critical'], + ThreshDastLow = config['dast']['low'], + ThreshDastMedium = config['dast']['medium'], + ThreshDastHigh = config['dast']['high'], + ThreshDastCritical = config['dast']['critical'], + ThreshDastApiLow = config['dastapi']['low'], + ThreshDastApiMedium = config['dastapi']['medium'], + ThreshDastApiHigh = config['dastapi']['high'], + ThreshDastApiCritical = config['dastapi']['critical'], + ThreshInfrastructureLow = config['infrastructure']['low'], + ThreshInfrastructureMedium = config['infrastructure']['medium'], + ThreshInfrastructureHigh = config['infrastructure']['high'], + ThreshInfrastructureCritical = config['infrastructure']['critical'], + ThreshSastLow = config['sast']['low'], + ThreshSastMedium = config['sast']['medium'], + ThreshSastHigh = config['sast']['high'], + ThreshSastCritical = config['sast']['critical'], + ThreshIacLow = config['iac']['low'], + ThreshIacMedium = config['iac']['medium'], + ThreshIacHigh = config['iac']['high'], + ThreshIacCritical = config['iac']['critical'], + ThreshSecretsLow = config['secret']['low'], + ThreshSecretsMedium = config['secret']['medium'], + ThreshSecretsHigh = config['secret']['high'], + ThreshSecretsCritical = config['secret']['critical'], ) db.session.add(job) db_connection_handler(db) @@ -92,38 +92,38 @@ def _add_sg_results(results, job_id, app_id): job = SgResultsPerJob( AppID=app_id, PipelineJobID=job_id, - ResultScaLow=results['report']['sca']['low'], - ResultScaMedium=results['report']['sca']['medium'], - ResultScaHigh=results['report']['sca']['high'], - ResultScaCritical=results['report']['sca']['critical'], - ResultContainerLow=results['report']['container']['low'], - ResultContainerMedium=results['report']['container']['medium'], - ResultContainerHigh=results['report']['container']['high'], - ResultContainerCritical=results['report']['container']['critical'], - ResultDastLow=results['report']['dast']['low'], - ResultDastMedium=results['report']['dast']['medium'], - ResultDastHigh=results['report']['dast']['high'], - ResultDastCritical=results['report']['dast']['critical'], - ResultDastApiLow=results['report']['dastapi']['low'], - ResultDastApiMedium=results['report']['dastapi']['medium'], - ResultDastApiHigh=results['report']['dastapi']['high'], - ResultDastApiCritical=results['report']['dastapi']['critical'], - ResultInfrastructureLow=results['report']['infrastructure']['low'], - ResultInfrastructureMedium=results['report']['infrastructure']['medium'], - ResultInfrastructureHigh=results['report']['infrastructure']['high'], - ResultInfrastructureCritical=results['report']['infrastructure']['critical'], - ResultSastLow=results['report']['sast']['low'], - ResultSastMedium=results['report']['sast']['medium'], - ResultSastHigh=results['report']['sast']['high'], - ResultSastCritical=results['report']['sast']['critical'], - ResultIacLow=results['report']['iac']['low'], - ResultIacMedium=results['report']['iac']['medium'], - ResultIacHigh=results['report']['iac']['high'], - ResultIacCritical=results['report']['iac']['critical'], - ResultSecretsLow=results['report']['secret']['low'], - ResultSecretsMedium=results['report']['secret']['medium'], - ResultSecretsHigh=results['report']['secret']['high'], - ResultSecretsCritical=results['report']['secret']['critical'], + ResultScaLow=results['sca']['low'], + ResultScaMedium=results['sca']['medium'], + ResultScaHigh=results['sca']['high'], + ResultScaCritical=results['sca']['critical'], + ResultContainerLow=results['container']['low'], + ResultContainerMedium=results['container']['medium'], + ResultContainerHigh=results['container']['high'], + ResultContainerCritical=results['container']['critical'], + ResultDastLow=results['dast']['low'], + ResultDastMedium=results['dast']['medium'], + ResultDastHigh=results['dast']['high'], + ResultDastCritical=results['dast']['critical'], + ResultDastApiLow=results['dastapi']['low'], + ResultDastApiMedium=results['dastapi']['medium'], + ResultDastApiHigh=results['dastapi']['high'], + ResultDastApiCritical=results['dastapi']['critical'], + ResultInfrastructureLow=results['infrastructure']['low'], + ResultInfrastructureMedium=results['infrastructure']['medium'], + ResultInfrastructureHigh=results['infrastructure']['high'], + ResultInfrastructureCritical=results['infrastructure']['critical'], + ResultSastLow=results['sast']['low'], + ResultSastMedium=results['sast']['medium'], + ResultSastHigh=results['sast']['high'], + ResultSastCritical=results['sast']['critical'], + ResultIacLow=results['iac']['low'], + ResultIacMedium=results['iac']['medium'], + ResultIacHigh=results['iac']['high'], + ResultIacCritical=results['iac']['critical'], + ResultSecretsLow=results['secret']['low'], + ResultSecretsMedium=results['secret']['medium'], + ResultSecretsHigh=results['secret']['high'], + ResultSecretsCritical=results['secret']['critical'], ) db.session.add(job) db_connection_handler(db) From 1a5e69ee64ab912c8ef32fd599938bac3dd7ef7e Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 12 Mar 2024 19:34:30 -0700 Subject: [PATCH 045/197] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index bac83770..f45ebce2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,7 +21,7 @@ pipeline { env.GLOBAL_BRANCH_LIST = config.global.defaultBranches.join(',') env.CURRENT_STAGE_BRANCH_LIST = "" - jslStageWrapper.initReport() + jslStageWrapper.initReport(config) } } From b4c8b1d574803b54f8e9552d0ebbd904d03b1f90 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 12 Mar 2024 19:40:15 -0700 Subject: [PATCH 046/197] Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index bac83770..f45ebce2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,7 +21,7 @@ pipeline { env.GLOBAL_BRANCH_LIST = config.global.defaultBranches.join(',') env.CURRENT_STAGE_BRANCH_LIST = "" - jslStageWrapper.initReport() + jslStageWrapper.initReport(config) } } From 067b847173c3ac49e991c7b30de6fa9373f3588a Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 12 Mar 2024 19:41:08 -0700 Subject: [PATCH 047/197] Release/0.1.0 beta/prod azure (#498) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index bac83770..f45ebce2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,7 +21,7 @@ pipeline { env.GLOBAL_BRANCH_LIST = config.global.defaultBranches.join(',') env.CURRENT_STAGE_BRANCH_LIST = "" - jslStageWrapper.initReport() + jslStageWrapper.initReport(config) } } From 12cbbd2e263570bd76cfae4692eac374d6c432c1 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 12 Mar 2024 20:16:37 -0700 Subject: [PATCH 048/197] Update security_quality_gate.py --- src/vr/api/vulns/security_quality_gate.py | 64 +++++++++++------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/vr/api/vulns/security_quality_gate.py b/src/vr/api/vulns/security_quality_gate.py index b00c1b1e..29c4191a 100644 --- a/src/vr/api/vulns/security_quality_gate.py +++ b/src/vr/api/vulns/security_quality_gate.py @@ -51,38 +51,38 @@ def _add_sg_config_settings(config, job_id, app_id): job = SgConfigSettingsPerJob( AppID=app_id, PipelineJobID = job_id, - ThreshScaLow = config['sca']['low'], - ThreshScaMedium = config['sca']['medium'], - ThreshScaHigh = config['sca']['high'], - ThreshScaCritical = config['sca']['critical'], - ThreshContainerLow = config['container']['low'], - ThreshContainerMedium = config['container']['medium'], - ThreshContainerHigh = config['container']['high'], - ThreshContainerCritical = config['container']['critical'], - ThreshDastLow = config['dast']['low'], - ThreshDastMedium = config['dast']['medium'], - ThreshDastHigh = config['dast']['high'], - ThreshDastCritical = config['dast']['critical'], - ThreshDastApiLow = config['dastapi']['low'], - ThreshDastApiMedium = config['dastapi']['medium'], - ThreshDastApiHigh = config['dastapi']['high'], - ThreshDastApiCritical = config['dastapi']['critical'], - ThreshInfrastructureLow = config['infrastructure']['low'], - ThreshInfrastructureMedium = config['infrastructure']['medium'], - ThreshInfrastructureHigh = config['infrastructure']['high'], - ThreshInfrastructureCritical = config['infrastructure']['critical'], - ThreshSastLow = config['sast']['low'], - ThreshSastMedium = config['sast']['medium'], - ThreshSastHigh = config['sast']['high'], - ThreshSastCritical = config['sast']['critical'], - ThreshIacLow = config['iac']['low'], - ThreshIacMedium = config['iac']['medium'], - ThreshIacHigh = config['iac']['high'], - ThreshIacCritical = config['iac']['critical'], - ThreshSecretsLow = config['secret']['low'], - ThreshSecretsMedium = config['secret']['medium'], - ThreshSecretsHigh = config['secret']['high'], - ThreshSecretsCritical = config['secret']['critical'], + ThreshScaLow = config['sca']['low'] if 'low' in 'sca' else '', + ThreshScaMedium = config['sca']['medium'] if 'medium' in 'sca' else '', + ThreshScaHigh = config['sca']['high'] if 'high' in 'sca' else '', + ThreshScaCritical = config['sca']['critical'] if 'critical' in 'sca' else '', + ThreshContainerLow = config['container']['low'] if 'low' in 'container' else '', + ThreshContainerMedium = config['container']['medium'] if 'medium' in 'container' else '', + ThreshContainerHigh = config['container']['high'] if 'high' in 'container' else '', + ThreshContainerCritical = config['container']['critical'] if 'critical' in 'container' else '', + ThreshDastLow = config['dast']['low'] if 'low' in 'dast' else '', + ThreshDastMedium = config['dast']['medium'] if 'medium' in 'dast' else '', + ThreshDastHigh = config['dast']['high'] if 'high' in 'dast' else '', + ThreshDastCritical = config['dast']['critical'] if 'critical' in 'dast' else '', + ThreshDastApiLow = config['dastapi']['low'] if 'low' in 'dastapi' else '', + ThreshDastApiMedium = config['dastapi']['medium'] if 'medium' in 'dastapi' else '', + ThreshDastApiHigh = config['dastapi']['high'] if 'high' in 'dastapi' else '', + ThreshDastApiCritical = config['dastapi']['critical'] if 'critical' in 'dastapi' else '', + ThreshInfrastructureLow = config['infrastructure']['low'] if 'low' in 'infrastructure' else '', + ThreshInfrastructureMedium = config['infrastructure']['medium'] if 'medium' in 'infrastructure' else '', + ThreshInfrastructureHigh = config['infrastructure']['high'] if 'high' in 'infrastructure' else '', + ThreshInfrastructureCritical = config['infrastructure']['critical'] if 'critical' in 'infrastructure' else '', + ThreshSastLow = config['sast']['low'] if 'low' in 'sast' else '', + ThreshSastMedium = config['sast']['medium'] if 'medium' in 'sast' else '', + ThreshSastHigh = config['sast']['high'] if 'high' in 'sast' else '', + ThreshSastCritical = config['sast']['critical'] if 'critical' in 'sast' else '', + ThreshIacLow = config['iac']['low'] if 'low' in 'iac' else '', + ThreshIacMedium = config['iac']['medium'] if 'medium' in 'iac' else '', + ThreshIacHigh = config['iac']['high'] if 'high' in 'iac' else '', + ThreshIacCritical = config['iac']['critical'] if 'critical' in 'iac' else '', + ThreshSecretsLow = config['secret']['low'] if 'low' in 'secret' else '', + ThreshSecretsMedium = config['secret']['medium'] if 'medium' in 'secret' else '', + ThreshSecretsHigh = config['secret']['high'] if 'high' in 'secret' else '', + ThreshSecretsCritical = config['secret']['critical'] if 'critical' in 'secret' else '', ) db.session.add(job) db_connection_handler(db) From 0cc02a42eb089f33dc0e9eca4dd22031771a7b4d Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 12 Mar 2024 20:22:58 -0700 Subject: [PATCH 049/197] Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py --- src/vr/api/vulns/security_quality_gate.py | 64 +++++++++++------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/vr/api/vulns/security_quality_gate.py b/src/vr/api/vulns/security_quality_gate.py index b00c1b1e..29c4191a 100644 --- a/src/vr/api/vulns/security_quality_gate.py +++ b/src/vr/api/vulns/security_quality_gate.py @@ -51,38 +51,38 @@ def _add_sg_config_settings(config, job_id, app_id): job = SgConfigSettingsPerJob( AppID=app_id, PipelineJobID = job_id, - ThreshScaLow = config['sca']['low'], - ThreshScaMedium = config['sca']['medium'], - ThreshScaHigh = config['sca']['high'], - ThreshScaCritical = config['sca']['critical'], - ThreshContainerLow = config['container']['low'], - ThreshContainerMedium = config['container']['medium'], - ThreshContainerHigh = config['container']['high'], - ThreshContainerCritical = config['container']['critical'], - ThreshDastLow = config['dast']['low'], - ThreshDastMedium = config['dast']['medium'], - ThreshDastHigh = config['dast']['high'], - ThreshDastCritical = config['dast']['critical'], - ThreshDastApiLow = config['dastapi']['low'], - ThreshDastApiMedium = config['dastapi']['medium'], - ThreshDastApiHigh = config['dastapi']['high'], - ThreshDastApiCritical = config['dastapi']['critical'], - ThreshInfrastructureLow = config['infrastructure']['low'], - ThreshInfrastructureMedium = config['infrastructure']['medium'], - ThreshInfrastructureHigh = config['infrastructure']['high'], - ThreshInfrastructureCritical = config['infrastructure']['critical'], - ThreshSastLow = config['sast']['low'], - ThreshSastMedium = config['sast']['medium'], - ThreshSastHigh = config['sast']['high'], - ThreshSastCritical = config['sast']['critical'], - ThreshIacLow = config['iac']['low'], - ThreshIacMedium = config['iac']['medium'], - ThreshIacHigh = config['iac']['high'], - ThreshIacCritical = config['iac']['critical'], - ThreshSecretsLow = config['secret']['low'], - ThreshSecretsMedium = config['secret']['medium'], - ThreshSecretsHigh = config['secret']['high'], - ThreshSecretsCritical = config['secret']['critical'], + ThreshScaLow = config['sca']['low'] if 'low' in 'sca' else '', + ThreshScaMedium = config['sca']['medium'] if 'medium' in 'sca' else '', + ThreshScaHigh = config['sca']['high'] if 'high' in 'sca' else '', + ThreshScaCritical = config['sca']['critical'] if 'critical' in 'sca' else '', + ThreshContainerLow = config['container']['low'] if 'low' in 'container' else '', + ThreshContainerMedium = config['container']['medium'] if 'medium' in 'container' else '', + ThreshContainerHigh = config['container']['high'] if 'high' in 'container' else '', + ThreshContainerCritical = config['container']['critical'] if 'critical' in 'container' else '', + ThreshDastLow = config['dast']['low'] if 'low' in 'dast' else '', + ThreshDastMedium = config['dast']['medium'] if 'medium' in 'dast' else '', + ThreshDastHigh = config['dast']['high'] if 'high' in 'dast' else '', + ThreshDastCritical = config['dast']['critical'] if 'critical' in 'dast' else '', + ThreshDastApiLow = config['dastapi']['low'] if 'low' in 'dastapi' else '', + ThreshDastApiMedium = config['dastapi']['medium'] if 'medium' in 'dastapi' else '', + ThreshDastApiHigh = config['dastapi']['high'] if 'high' in 'dastapi' else '', + ThreshDastApiCritical = config['dastapi']['critical'] if 'critical' in 'dastapi' else '', + ThreshInfrastructureLow = config['infrastructure']['low'] if 'low' in 'infrastructure' else '', + ThreshInfrastructureMedium = config['infrastructure']['medium'] if 'medium' in 'infrastructure' else '', + ThreshInfrastructureHigh = config['infrastructure']['high'] if 'high' in 'infrastructure' else '', + ThreshInfrastructureCritical = config['infrastructure']['critical'] if 'critical' in 'infrastructure' else '', + ThreshSastLow = config['sast']['low'] if 'low' in 'sast' else '', + ThreshSastMedium = config['sast']['medium'] if 'medium' in 'sast' else '', + ThreshSastHigh = config['sast']['high'] if 'high' in 'sast' else '', + ThreshSastCritical = config['sast']['critical'] if 'critical' in 'sast' else '', + ThreshIacLow = config['iac']['low'] if 'low' in 'iac' else '', + ThreshIacMedium = config['iac']['medium'] if 'medium' in 'iac' else '', + ThreshIacHigh = config['iac']['high'] if 'high' in 'iac' else '', + ThreshIacCritical = config['iac']['critical'] if 'critical' in 'iac' else '', + ThreshSecretsLow = config['secret']['low'] if 'low' in 'secret' else '', + ThreshSecretsMedium = config['secret']['medium'] if 'medium' in 'secret' else '', + ThreshSecretsHigh = config['secret']['high'] if 'high' in 'secret' else '', + ThreshSecretsCritical = config['secret']['critical'] if 'critical' in 'secret' else '', ) db.session.add(job) db_connection_handler(db) From 016fe0da82ff79136bd0d73240139196e5d6936a Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 12 Mar 2024 20:24:01 -0700 Subject: [PATCH 050/197] Release/0.1.0 beta/prod azure (#500) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile * Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py --- src/vr/api/vulns/security_quality_gate.py | 64 +++++++++++------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/vr/api/vulns/security_quality_gate.py b/src/vr/api/vulns/security_quality_gate.py index b00c1b1e..29c4191a 100644 --- a/src/vr/api/vulns/security_quality_gate.py +++ b/src/vr/api/vulns/security_quality_gate.py @@ -51,38 +51,38 @@ def _add_sg_config_settings(config, job_id, app_id): job = SgConfigSettingsPerJob( AppID=app_id, PipelineJobID = job_id, - ThreshScaLow = config['sca']['low'], - ThreshScaMedium = config['sca']['medium'], - ThreshScaHigh = config['sca']['high'], - ThreshScaCritical = config['sca']['critical'], - ThreshContainerLow = config['container']['low'], - ThreshContainerMedium = config['container']['medium'], - ThreshContainerHigh = config['container']['high'], - ThreshContainerCritical = config['container']['critical'], - ThreshDastLow = config['dast']['low'], - ThreshDastMedium = config['dast']['medium'], - ThreshDastHigh = config['dast']['high'], - ThreshDastCritical = config['dast']['critical'], - ThreshDastApiLow = config['dastapi']['low'], - ThreshDastApiMedium = config['dastapi']['medium'], - ThreshDastApiHigh = config['dastapi']['high'], - ThreshDastApiCritical = config['dastapi']['critical'], - ThreshInfrastructureLow = config['infrastructure']['low'], - ThreshInfrastructureMedium = config['infrastructure']['medium'], - ThreshInfrastructureHigh = config['infrastructure']['high'], - ThreshInfrastructureCritical = config['infrastructure']['critical'], - ThreshSastLow = config['sast']['low'], - ThreshSastMedium = config['sast']['medium'], - ThreshSastHigh = config['sast']['high'], - ThreshSastCritical = config['sast']['critical'], - ThreshIacLow = config['iac']['low'], - ThreshIacMedium = config['iac']['medium'], - ThreshIacHigh = config['iac']['high'], - ThreshIacCritical = config['iac']['critical'], - ThreshSecretsLow = config['secret']['low'], - ThreshSecretsMedium = config['secret']['medium'], - ThreshSecretsHigh = config['secret']['high'], - ThreshSecretsCritical = config['secret']['critical'], + ThreshScaLow = config['sca']['low'] if 'low' in 'sca' else '', + ThreshScaMedium = config['sca']['medium'] if 'medium' in 'sca' else '', + ThreshScaHigh = config['sca']['high'] if 'high' in 'sca' else '', + ThreshScaCritical = config['sca']['critical'] if 'critical' in 'sca' else '', + ThreshContainerLow = config['container']['low'] if 'low' in 'container' else '', + ThreshContainerMedium = config['container']['medium'] if 'medium' in 'container' else '', + ThreshContainerHigh = config['container']['high'] if 'high' in 'container' else '', + ThreshContainerCritical = config['container']['critical'] if 'critical' in 'container' else '', + ThreshDastLow = config['dast']['low'] if 'low' in 'dast' else '', + ThreshDastMedium = config['dast']['medium'] if 'medium' in 'dast' else '', + ThreshDastHigh = config['dast']['high'] if 'high' in 'dast' else '', + ThreshDastCritical = config['dast']['critical'] if 'critical' in 'dast' else '', + ThreshDastApiLow = config['dastapi']['low'] if 'low' in 'dastapi' else '', + ThreshDastApiMedium = config['dastapi']['medium'] if 'medium' in 'dastapi' else '', + ThreshDastApiHigh = config['dastapi']['high'] if 'high' in 'dastapi' else '', + ThreshDastApiCritical = config['dastapi']['critical'] if 'critical' in 'dastapi' else '', + ThreshInfrastructureLow = config['infrastructure']['low'] if 'low' in 'infrastructure' else '', + ThreshInfrastructureMedium = config['infrastructure']['medium'] if 'medium' in 'infrastructure' else '', + ThreshInfrastructureHigh = config['infrastructure']['high'] if 'high' in 'infrastructure' else '', + ThreshInfrastructureCritical = config['infrastructure']['critical'] if 'critical' in 'infrastructure' else '', + ThreshSastLow = config['sast']['low'] if 'low' in 'sast' else '', + ThreshSastMedium = config['sast']['medium'] if 'medium' in 'sast' else '', + ThreshSastHigh = config['sast']['high'] if 'high' in 'sast' else '', + ThreshSastCritical = config['sast']['critical'] if 'critical' in 'sast' else '', + ThreshIacLow = config['iac']['low'] if 'low' in 'iac' else '', + ThreshIacMedium = config['iac']['medium'] if 'medium' in 'iac' else '', + ThreshIacHigh = config['iac']['high'] if 'high' in 'iac' else '', + ThreshIacCritical = config['iac']['critical'] if 'critical' in 'iac' else '', + ThreshSecretsLow = config['secret']['low'] if 'low' in 'secret' else '', + ThreshSecretsMedium = config['secret']['medium'] if 'medium' in 'secret' else '', + ThreshSecretsHigh = config['secret']['high'] if 'high' in 'secret' else '', + ThreshSecretsCritical = config['secret']['critical'] if 'critical' in 'secret' else '', ) db.session.add(job) db_connection_handler(db) From c5242c921e8af6ec7aee9320f94de9bba4254722 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sun, 17 Mar 2024 18:13:34 -0700 Subject: [PATCH 051/197] update settings and groups --- src/vr/admin/models.py | 37 ++++ src/vr/admin/routes/settings.py | 303 +++++++++++++++++++++++---- src/vr/db_models/setup.py | 37 ++++ src/vr/templates/admin/settings.html | 281 ++++++++++++++++++++++++- 4 files changed, 615 insertions(+), 43 deletions(-) diff --git a/src/vr/admin/models.py b/src/vr/admin/models.py index 1048b3d0..89785772 100644 --- a/src/vr/admin/models.py +++ b/src/vr/admin/models.py @@ -416,6 +416,43 @@ class AppConfig(db.Model): __tablename__ = 'AppConfig' id = db.Column(db.Integer, primary_key=True) first_access = db.Column(db.Boolean, nullable=False, default=True) + settings_initialized = db.Column(db.Boolean, nullable=False, default=False) + APP_EXT_URL = db.Column(db.String(200)) + AUTH_TYPE = db.Column(db.String(200)) + AZAD_AUTHORITY = db.Column(db.String(200)) + AZAD_CLIENT_ID = db.Column(db.String(200)) + AZAD_CLIENT_SECRET = db.Column(db.String(200)) + AZURE_KEYVAULT_NAME = db.Column(db.String(200)) + ENV = db.Column(db.String(200)) + INSECURE_OAUTH = db.Column(db.String(200)) + JENKINS_HOST = db.Column(db.String(200)) + JENKINS_KEY = db.Column(db.String(200)) + JENKINS_PROJECT = db.Column(db.String(200)) + JENKINS_STAGING_PROJECT = db.Column(db.String(200)) + JENKINS_TOKEN = db.Column(db.String(200)) + JENKINS_USER = db.Column(db.String(200)) + LDAP_BASE_DN = db.Column(db.String(200)) + LDAP_BIND_USER_DN = db.Column(db.String(200)) + LDAP_BIND_USER_PASSWORD = db.Column(db.String(200)) + LDAP_GROUP_DN = db.Column(db.String(200)) + LDAP_HOST = db.Column(db.String(200)) + LDAP_PORT = db.Column(db.String(200)) + LDAP_USER_DN = db.Column(db.String(200)) + LDAP_USER_LOGIN_ATTR = db.Column(db.String(200)) + LDAP_USER_RDN_ATTR = db.Column(db.String(200)) + PROD_DB_URI = db.Column(db.String(200)) + SMTP_ADMIN_EMAIL = db.Column(db.String(200)) + SMTP_HOST = db.Column(db.String(200)) + SMTP_PASSWORD = db.Column(db.String(200)) + SMTP_USER = db.Column(db.String(200)) + SNOW_CLIENT_ID = db.Column(db.String(200)) + SNOW_CLIENT_SECRET = db.Column(db.String(200)) + SNOW_INSTANCE_NAME = db.Column(db.String(200)) + SNOW_PASSWORD = db.Column(db.String(200)) + SNOW_USERNAME = db.Column(db.String(200)) + VERSION = db.Column(db.String(200)) + JENKINS_ENABLED = db.Column(db.String(200)) + SNOW_ENABLED = db.Column(db.String(200)) class SuSiteConfiguration(db.Model): diff --git a/src/vr/admin/routes/settings.py b/src/vr/admin/routes/settings.py index c366ce43..a3125e54 100644 --- a/src/vr/admin/routes/settings.py +++ b/src/vr/admin/routes/settings.py @@ -1,4 +1,4 @@ -from flask import session, redirect, url_for, render_template +from flask import session, redirect, url_for, render_template, request from flask_login import login_required from vr import db, app import os @@ -10,14 +10,18 @@ AZAD_CLIENT_ID, AZAD_CLIENT_SECRET, AZAD_AUTHORITY, JENKINS_USER, AZURE_KEYVAULT_NAME, INSECURE_OAUTH, \ JENKINS_HOST, JENKINS_KEY, JENKINS_PROJECT, JENKINS_STAGING_PROJECT, JENKINS_TOKEN, SMTP_ADMIN_EMAIL, \ SMTP_HOST, SMTP_PASSWORD, SMTP_USER, SNOW_CLIENT_ID, SNOW_CLIENT_SECRET, SNOW_INSTANCE_NAME, SNOW_PASSWORD, \ - SNOW_USERNAME, VERSION + SNOW_USERNAME, VERSION, JENKINS_ENABLED, SNOW_ENABLED from flask_sqlalchemy import SQLAlchemy +from vr.admin.models import AppConfig +from vr.admin.functions import db_connection_handler +from sqlalchemy import text + NAV = { 'CAT': { "name": "Settings", "url": "admin.admin_dashboard"} } -@admin.route('/settings', methods=['GET']) +@admin.route('/settings', methods=['GET', 'POST']) @login_required def settings(): NAV['curpage'] = {"name": "Settings"} @@ -27,44 +31,263 @@ def settings(): elif status == 403: return render_template('403.html', user=user, nav_cat={}, nav_subcat='', \ nav_subsubcat='', nav_curpage={"name": "Unauthorized"}) - current_settings = { - "APP_EXT_URL": APP_EXT_URL, - "AUTH_TYPE": AUTH_TYPE, - "AZAD_AUTHORITY":AZAD_AUTHORITY, - "AZAD_CLIENT_ID": AZAD_CLIENT_ID, - "AZAD_CLIENT_SECRET": AZAD_CLIENT_SECRET, - "AZURE_KEYVAULT_NAME": AZURE_KEYVAULT_NAME, - "ENV": ENV, - "INSECURE_OAUTH": INSECURE_OAUTH, - "JENKINS_HOST": JENKINS_HOST, - "JENKINS_KEY": JENKINS_KEY, - "JENKINS_PROJECT": JENKINS_PROJECT, - "JENKINS_STAGING_PROJECT": JENKINS_STAGING_PROJECT, - "JENKINS_TOKEN": JENKINS_TOKEN, - "JENKINS_USER": JENKINS_USER, - "LDAP_BASE_DN": LDAP_BASE_DN, - "LDAP_BIND_USER_DN": LDAP_BIND_USER_DN, - "LDAP_BIND_USER_PASSWORD": LDAP_BIND_USER_PASSWORD, - "LDAP_GROUP_DN": LDAP_GROUP_DN, - "LDAP_HOST": LDAP_HOST, - "LDAP_PORT": LDAP_PORT, - "LDAP_USER_DN": LDAP_USER_DN, - "LDAP_USER_LOGIN_ATTR": LDAP_USER_LOGIN_ATTR, - "LDAP_USER_RDN_ATTR": LDAP_USER_RDN_ATTR, - "PROD_DB_URI": PROD_DB_URI, - "SMTP_ADMIN_EMAIL": SMTP_ADMIN_EMAIL, - "SMTP_HOST": SMTP_HOST, - "SMTP_PASSWORD": SMTP_PASSWORD, - "SMTP_USER": SMTP_USER, - "SNOW_CLIENT_ID": SNOW_CLIENT_ID, - "SNOW_CLIENT_SECRET": SNOW_CLIENT_SECRET, - "SNOW_INSTANCE_NAME": SNOW_INSTANCE_NAME, - "SNOW_PASSWORD": SNOW_PASSWORD, - "SNOW_USERNAME": SNOW_USERNAME, - "VERSION": VERSION, - } + if request.method == 'POST': + app_config = AppConfig.query.first() + + all = request.form + update_json = { + AppConfig.JENKINS_ENABLED: all["JENKINS_ENABLED"], + AppConfig.SNOW_ENABLED: all["SNOW_ENABLED"], + AppConfig.APP_EXT_URL: all["APP_EXT_URL"], + AppConfig.AUTH_TYPE: all["AUTH_TYPE"], + AppConfig.AZAD_AUTHORITY: all["AZAD_AUTHORITY"], + AppConfig.AZAD_CLIENT_ID: all["AZAD_CLIENT_ID"], + AppConfig.AZAD_CLIENT_SECRET: all["AZAD_CLIENT_SECRET"], + AppConfig.AZURE_KEYVAULT_NAME: all["AZURE_KEYVAULT_NAME"], + AppConfig.ENV: all["ENV"], + AppConfig.INSECURE_OAUTH: all["INSECURE_OAUTH"], + AppConfig.JENKINS_HOST: all["JENKINS_HOST"], + AppConfig.JENKINS_KEY: all["JENKINS_KEY"], + AppConfig.JENKINS_PROJECT: all["JENKINS_PROJECT"], + AppConfig.JENKINS_STAGING_PROJECT: all["JENKINS_STAGING_PROJECT"], + AppConfig.JENKINS_TOKEN: all["JENKINS_TOKEN"], + AppConfig.JENKINS_USER: all["JENKINS_USER"], + AppConfig.LDAP_BASE_DN: all["LDAP_BASE_DN"], + AppConfig.LDAP_BIND_USER_DN: all["LDAP_BIND_USER_DN"], + AppConfig.LDAP_BIND_USER_PASSWORD: all["LDAP_BIND_USER_PASSWORD"], + AppConfig.LDAP_GROUP_DN: all["LDAP_GROUP_DN"], + AppConfig.LDAP_HOST: all["LDAP_HOST"], + AppConfig.LDAP_PORT: all["LDAP_PORT"], + AppConfig.LDAP_USER_DN: all["LDAP_USER_DN"], + AppConfig.LDAP_USER_LOGIN_ATTR: all["LDAP_USER_LOGIN_ATTR"], + AppConfig.LDAP_USER_RDN_ATTR: all["LDAP_USER_RDN_ATTR"], + AppConfig.PROD_DB_URI: all["PROD_DB_URI"], + AppConfig.SMTP_ADMIN_EMAIL: all["SMTP_ADMIN_EMAIL"], + AppConfig.SMTP_HOST: all["SMTP_HOST"], + AppConfig.SMTP_PASSWORD: all["SMTP_PASSWORD"], + AppConfig.SMTP_USER: all["SMTP_USER"], + AppConfig.SNOW_CLIENT_ID: all["SNOW_CLIENT_ID"], + AppConfig.SNOW_CLIENT_SECRET: all["SNOW_CLIENT_SECRET"], + AppConfig.SNOW_INSTANCE_NAME: all["SNOW_INSTANCE_NAME"], + AppConfig.SNOW_PASSWORD: all["SNOW_PASSWORD"], + AppConfig.SNOW_USERNAME: all["SNOW_USERNAME"], + AppConfig.VERSION: all["VERSION"], + } + if not app_config.settings_initialized: + update_json[AppConfig.settings_initialized] = True + db.session.query(AppConfig) \ + .update(update_json, synchronize_session=False) + db_connection_handler(db) + set_env_variables(all) + current_settings = { + "JENKINS_ENABLED": all["JENKINS_ENABLED"], + "SNOW_ENABLED": all["SNOW_ENABLED"], + "APP_EXT_URL": all["APP_EXT_URL"], + "AUTH_TYPE": all["AUTH_TYPE"], + "AZAD_AUTHORITY": all["AZAD_AUTHORITY"], + "AZAD_CLIENT_ID": all["AZAD_CLIENT_ID"], + "AZAD_CLIENT_SECRET": all["AZAD_CLIENT_SECRET"], + "AZURE_KEYVAULT_NAME": all["AZURE_KEYVAULT_NAME"], + "ENV": all["ENV"], + "INSECURE_OAUTH": all["INSECURE_OAUTH"], + "JENKINS_HOST": all["JENKINS_HOST"], + "JENKINS_KEY": all["JENKINS_KEY"], + "JENKINS_PROJECT": all["JENKINS_PROJECT"], + "JENKINS_STAGING_PROJECT": all["JENKINS_STAGING_PROJECT"], + "JENKINS_TOKEN": all["JENKINS_TOKEN"], + "JENKINS_USER": all["JENKINS_USER"], + "LDAP_BASE_DN": all["LDAP_BASE_DN"], + "LDAP_BIND_USER_DN": all["LDAP_BIND_USER_DN"], + "LDAP_BIND_USER_PASSWORD": all["LDAP_BIND_USER_PASSWORD"], + "LDAP_GROUP_DN": all["LDAP_GROUP_DN"], + "LDAP_HOST": all["LDAP_HOST"], + "LDAP_PORT": all["LDAP_PORT"], + "LDAP_USER_DN": all["LDAP_USER_DN"], + "LDAP_USER_LOGIN_ATTR": all["LDAP_USER_LOGIN_ATTR"], + "LDAP_USER_RDN_ATTR": all["LDAP_USER_RDN_ATTR"], + "PROD_DB_URI": all["PROD_DB_URI"], + "SMTP_ADMIN_EMAIL": all["SMTP_ADMIN_EMAIL"], + "SMTP_HOST": all["SMTP_HOST"], + "SMTP_PASSWORD": all["SMTP_PASSWORD"], + "SMTP_USER": all["SMTP_USER"], + "SNOW_CLIENT_ID": all["SNOW_CLIENT_ID"], + "SNOW_CLIENT_SECRET": all["SNOW_CLIENT_SECRET"], + "SNOW_INSTANCE_NAME": all["SNOW_INSTANCE_NAME"], + "SNOW_PASSWORD": all["SNOW_PASSWORD"], + "SNOW_USERNAME": all["SNOW_USERNAME"], + "VERSION": all["VERSION"], + } + else: + app_config = AppConfig.query.first() + if app_config.settings_initialized: + current_settings = { + "JENKINS_ENABLED": app_config.JENKINS_ENABLED, + "SNOW_ENABLED": app_config.SNOW_ENABLED, + "APP_EXT_URL": app_config.APP_EXT_URL, + "AUTH_TYPE": app_config.AUTH_TYPE, + "AZAD_AUTHORITY": app_config.AZAD_AUTHORITY, + "AZAD_CLIENT_ID": app_config.AZAD_CLIENT_ID, + "AZAD_CLIENT_SECRET": app_config.AZAD_CLIENT_SECRET, + "AZURE_KEYVAULT_NAME": app_config.AZURE_KEYVAULT_NAME, + "ENV": app_config.ENV, + "INSECURE_OAUTH": app_config.INSECURE_OAUTH, + "JENKINS_HOST": app_config.JENKINS_HOST, + "JENKINS_KEY": app_config.JENKINS_KEY, + "JENKINS_PROJECT": app_config.JENKINS_PROJECT, + "JENKINS_STAGING_PROJECT": app_config.JENKINS_STAGING_PROJECT, + "JENKINS_USER": app_config.JENKINS_USER, + "JENKINS_TOKEN": app_config.JENKINS_TOKEN, + "LDAP_BASE_DN": app_config.LDAP_BASE_DN, + "LDAP_BIND_USER_DN": app_config.LDAP_BIND_USER_DN, + "LDAP_BIND_USER_PASSWORD": app_config.LDAP_BIND_USER_PASSWORD, + "LDAP_GROUP_DN": app_config.LDAP_GROUP_DN, + "LDAP_HOST": app_config.LDAP_HOST, + "LDAP_PORT": app_config.LDAP_PORT, + "LDAP_USER_DN": app_config.LDAP_USER_DN, + "LDAP_USER_LOGIN_ATTR": app_config.LDAP_USER_LOGIN_ATTR, + "LDAP_USER_RDN_ATTR": app_config.LDAP_USER_RDN_ATTR, + "PROD_DB_URI": app_config.PROD_DB_URI, + "SMTP_ADMIN_EMAIL": app_config.SMTP_ADMIN_EMAIL, + "SMTP_HOST": app_config.SMTP_HOST, + "SMTP_USER": app_config.SMTP_USER, + "SMTP_PASSWORD": app_config.SMTP_PASSWORD, + "SNOW_CLIENT_ID": app_config.SNOW_CLIENT_ID, + "SNOW_CLIENT_SECRET": app_config.SNOW_CLIENT_SECRET, + "SNOW_INSTANCE_NAME": app_config.SNOW_INSTANCE_NAME, + "SNOW_USERNAME": app_config.SNOW_USERNAME, + "SNOW_PASSWORD": app_config.SNOW_PASSWORD, + "VERSION": app_config.VERSION, + } + else: + current_settings = { + "JENKINS_ENABLED": JENKINS_ENABLED, + "SNOW_ENABLED": SNOW_ENABLED, + "APP_EXT_URL": APP_EXT_URL, + "AUTH_TYPE": AUTH_TYPE, + "AZAD_AUTHORITY":AZAD_AUTHORITY, + "AZAD_CLIENT_ID": AZAD_CLIENT_ID, + "AZAD_CLIENT_SECRET": AZAD_CLIENT_SECRET, + "AZURE_KEYVAULT_NAME": AZURE_KEYVAULT_NAME, + "ENV": ENV, + "INSECURE_OAUTH": INSECURE_OAUTH, + "JENKINS_HOST": JENKINS_HOST, + "JENKINS_KEY": JENKINS_KEY, + "JENKINS_PROJECT": JENKINS_PROJECT, + "JENKINS_STAGING_PROJECT": JENKINS_STAGING_PROJECT, + "JENKINS_USER": JENKINS_USER, + "JENKINS_TOKEN": JENKINS_TOKEN, + "LDAP_BASE_DN": LDAP_BASE_DN, + "LDAP_BIND_USER_DN": LDAP_BIND_USER_DN, + "LDAP_BIND_USER_PASSWORD": LDAP_BIND_USER_PASSWORD, + "LDAP_GROUP_DN": LDAP_GROUP_DN, + "LDAP_HOST": LDAP_HOST, + "LDAP_PORT": LDAP_PORT, + "LDAP_USER_DN": LDAP_USER_DN, + "LDAP_USER_LOGIN_ATTR": LDAP_USER_LOGIN_ATTR, + "LDAP_USER_RDN_ATTR": LDAP_USER_RDN_ATTR, + "PROD_DB_URI": PROD_DB_URI, + "SMTP_ADMIN_EMAIL": SMTP_ADMIN_EMAIL, + "SMTP_HOST": SMTP_HOST, + "SMTP_USER": SMTP_USER, + "SMTP_PASSWORD": SMTP_PASSWORD, + "SNOW_CLIENT_ID": SNOW_CLIENT_ID, + "SNOW_CLIENT_SECRET": SNOW_CLIENT_SECRET, + "SNOW_INSTANCE_NAME": SNOW_INSTANCE_NAME, + "SNOW_USERNAME": SNOW_USERNAME, + "SNOW_PASSWORD": SNOW_PASSWORD, + "VERSION": VERSION, + } + cat_general = [ + 'APP_EXT_URL', + 'AUTH_TYPE', + 'ENV', + 'INSECURE_OAUTH', + 'PROD_DB_URI', + 'VERSION', + 'AZURE_KEYVAULT_NAME' + ] + cat_azad = [ + 'AZAD_AUTHORITY', + 'AZAD_CLIENT_ID', + 'AZAD_CLIENT_SECRET' + ] + cat_jenkins = [ + 'JENKINS_ENABLED', + 'JENKINS_HOST', + 'JENKINS_KEY', + 'JENKINS_PROJECT', + 'JENKINS_STAGING_PROJECT', + 'JENKINS_TOKEN', + 'JENKINS_USER' + ] + cat_ldap = [ + 'LDAP_BASE_DN', + 'LDAP_BIND_USER_DN', + 'LDAP_BIND_USER_PASSWORD', + 'LDAP_GROUP_DN', + 'LDAP_HOST', + 'LDAP_PORT', + 'LDAP_USER_DN', + 'LDAP_USER_LOGIN_ATTR', + 'LDAP_USER_RDN_ATTR' + ] + smtp_settings = [ + 'SMTP_ADMIN_EMAIL', + 'SMTP_HOST', + 'SMTP_PASSWORD', + 'SMTP_USER' + ] + snow_settings = [ + 'SNOW_ENABLED', + 'SNOW_CLIENT_ID', + 'SNOW_CLIENT_SECRET', + 'SNOW_INSTANCE_NAME', + 'SNOW_PASSWORD', + 'SNOW_USERNAME' + ] return render_template('admin/settings.html', user_roles=user_roles, NAV=NAV, - user=user, settings=current_settings) + user=user, settings=current_settings, cat_general=cat_general, + cat_azad=cat_azad, cat_jenkins=cat_jenkins, cat_ldap=cat_ldap, + smtp_settings=smtp_settings, snow_settings=snow_settings) + +def set_env_variables(form): + os.environ['APP_EXT_URL'] = form["APP_EXT_URL"] + os.environ['AUTH_TYPE'] = form["AUTH_TYPE"] + os.environ['AZAD_AUTHORITY'] = form["AZAD_AUTHORITY"] + os.environ['AZAD_CLIENT_ID'] = form["AZAD_CLIENT_ID"] + os.environ['AZAD_CLIENT_SECRET'] = form["AZAD_CLIENT_SECRET"] + os.environ['AZURE_KEYVAULT_NAME'] = form["AZURE_KEYVAULT_NAME"] + os.environ['ENV'] = form["ENV"] + os.environ['INSECURE_OAUTH'] = form["INSECURE_OAUTH"] + os.environ['JENKINS_ENABLED'] = form["JENKINS_ENABLED"] + os.environ['JENKINS_HOST'] = form["JENKINS_HOST"] + os.environ['JENKINS_KEY'] = form["JENKINS_KEY"] + os.environ['JENKINS_PROJECT'] = form["JENKINS_PROJECT"] + os.environ['JENKINS_STAGING_PROJECT'] = form["JENKINS_STAGING_PROJECT"] + os.environ['JENKINS_TOKEN'] = form["JENKINS_TOKEN"] + os.environ['JENKINS_USER'] = form["JENKINS_USER"] + os.environ['LDAP_BASE_DN'] = form["LDAP_BASE_DN"] + os.environ['LDAP_BIND_USER_DN'] = form["LDAP_BIND_USER_DN"] + os.environ['LDAP_BIND_USER_PASSWORD'] = form["LDAP_BIND_USER_PASSWORD"] + os.environ['LDAP_GROUP_DN'] = form["LDAP_GROUP_DN"] + os.environ['LDAP_HOST'] = form["LDAP_HOST"] + os.environ['LDAP_PORT'] = form["LDAP_PORT"] + os.environ['LDAP_USER_DN'] = form["LDAP_USER_DN"] + os.environ['LDAP_USER_LOGIN_ATTR'] = form["LDAP_USER_LOGIN_ATTR"] + os.environ['LDAP_USER_RDN_ATTR'] = form["LDAP_USER_RDN_ATTR"] + os.environ['PROD_DB_URI'] = form["PROD_DB_URI"] + os.environ['SMTP_ADMIN_EMAIL'] = form["SMTP_ADMIN_EMAIL"] + os.environ['SMTP_HOST'] = form["SMTP_HOST"] + os.environ['SMTP_PASSWORD'] = form["SMTP_PASSWORD"] + os.environ['SMTP_USER'] = form["SMTP_USER"] + os.environ['SNOW_ENABLED'] = form["SNOW_ENABLED"] + os.environ['SNOW_CLIENT_ID'] = form["SNOW_CLIENT_ID"] + os.environ['SNOW_CLIENT_SECRET'] = form["SNOW_CLIENT_SECRET"] + os.environ['SNOW_INSTANCE_NAME'] = form["SNOW_INSTANCE_NAME"] + os.environ['SNOW_PASSWORD'] = form["SNOW_PASSWORD"] + os.environ['SNOW_USERNAME'] = form["SNOW_USERNAME"] + os.environ['VERSION'] = form["VERSION"] + @admin.route('/dangerous/delete_all', methods=['POST']) def delete_all_data(): diff --git a/src/vr/db_models/setup.py b/src/vr/db_models/setup.py index 67adfc3b..b36fdc22 100644 --- a/src/vr/db_models/setup.py +++ b/src/vr/db_models/setup.py @@ -117,6 +117,43 @@ class AppConfig(db.Model): __table_args__ = {'extend_existing': True} id = db.Column(db.Integer, primary_key=True) first_access = db.Column(db.Boolean, nullable=False, default=True) + settings_initialized = db.Column(db.Boolean, nullable=False, default=False) + APP_EXT_URL = db.Column(db.String(200)) + AUTH_TYPE = db.Column(db.String(200)) + AZAD_AUTHORITY = db.Column(db.String(200)) + AZAD_CLIENT_ID = db.Column(db.String(200)) + AZAD_CLIENT_SECRET = db.Column(db.String(200)) + AZURE_KEYVAULT_NAME = db.Column(db.String(200)) + ENV = db.Column(db.String(200)) + INSECURE_OAUTH = db.Column(db.String(200)) + JENKINS_HOST = db.Column(db.String(200)) + JENKINS_KEY = db.Column(db.String(200)) + JENKINS_PROJECT = db.Column(db.String(200)) + JENKINS_STAGING_PROJECT = db.Column(db.String(200)) + JENKINS_TOKEN = db.Column(db.String(200)) + JENKINS_USER = db.Column(db.String(200)) + LDAP_BASE_DN = db.Column(db.String(200)) + LDAP_BIND_USER_DN = db.Column(db.String(200)) + LDAP_BIND_USER_PASSWORD = db.Column(db.String(200)) + LDAP_GROUP_DN = db.Column(db.String(200)) + LDAP_HOST = db.Column(db.String(200)) + LDAP_PORT = db.Column(db.String(200)) + LDAP_USER_DN = db.Column(db.String(200)) + LDAP_USER_LOGIN_ATTR = db.Column(db.String(200)) + LDAP_USER_RDN_ATTR = db.Column(db.String(200)) + PROD_DB_URI = db.Column(db.String(200)) + SMTP_ADMIN_EMAIL = db.Column(db.String(200)) + SMTP_HOST = db.Column(db.String(200)) + SMTP_PASSWORD = db.Column(db.String(200)) + SMTP_USER = db.Column(db.String(200)) + SNOW_CLIENT_ID = db.Column(db.String(200)) + SNOW_CLIENT_SECRET = db.Column(db.String(200)) + SNOW_INSTANCE_NAME = db.Column(db.String(200)) + SNOW_PASSWORD = db.Column(db.String(200)) + SNOW_USERNAME = db.Column(db.String(200)) + VERSION = db.Column(db.String(200)) + JENKINS_ENABLED = db.Column(db.String(200)) + SNOW_ENABLED = db.Column(db.String(200)) AppConfig() diff --git a/src/vr/templates/admin/settings.html b/src/vr/templates/admin/settings.html index 06a4bee5..a7564e1a 100644 --- a/src/vr/templates/admin/settings.html +++ b/src/vr/templates/admin/settings.html @@ -113,13 +113,135 @@

Application Settings

+ + +
+

General Settings

+ {% for key, value in settings.items() %} + {% if key in cat_general %} +
+ + {% if key == "AUTH_TYPE" %} + + {% elif key == "INSECURE_OAUTH" %} + + {% elif key == "PROD_DB_URI" %} +
+ {% elif key == "ENV" or key == "VERSION" %} + + {% else %} + + {% endif %} +
+ {% endif %} + {% endfor %} +
+ +
+

LDAP Settings

{% for key, value in settings.items() %} -
- - + {% if key in cat_ldap %} +
+ + +
+ {% endif %} + {% endfor %}
+ +
+

Azure Active Directory Settings

+ {% for key, value in settings.items() %} + {% if key in cat_azad %} +
+ + +
+ {% endif %} {% endfor %} +
+ +
+

SMTP Settings

+ {% for key, value in settings.items() %} + {% if key in smtp_settings %} +
+ + {% if key == 'SMTP_PASSWORD' %} +
+ {% else %} + + {% endif %} + +
+ {% endif %} + {% endfor %} +
+ +
+

Jenkins Settings

+ {% for key, value in settings.items() %} + {% if key in cat_jenkins %} +
+ {% if key == 'JENKINS_ENABLED' %} + + + {% elif key == 'JENKINS_KEY' %} + +
+ {% elif key == 'JENKINS_TOKEN' %} + +
+ {% else %} + + + {% endif %} +
+ {% endif %} + {% endfor %} +
+ + + + + +
+

ServiceNOW Settings

+ {% for key, value in settings.items() %} + {% if key in snow_settings %} +
+ {% if key == 'SNOW_ENABLED' %} + + + {% elif key == 'SNOW_CLIENT_SECRET' %} + +
+ {% elif key == 'SNOW_PASSWORD' %} + +
+ {% else %} + + + {% endif %} +
+ {% endif %} + {% endfor %} +
+
@@ -128,4 +250,157 @@

Application Settings

+ + {% endblock %} From 0cab74cda8c3939b81e5bbbdf39f2c35008df75b Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sun, 17 Mar 2024 18:22:04 -0700 Subject: [PATCH 052/197] Feature/update settings function (#501) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups --- src/vr/admin/models.py | 37 ++++ src/vr/admin/routes/settings.py | 303 +++++++++++++++++++++++---- src/vr/db_models/setup.py | 37 ++++ src/vr/templates/admin/settings.html | 281 ++++++++++++++++++++++++- 4 files changed, 615 insertions(+), 43 deletions(-) diff --git a/src/vr/admin/models.py b/src/vr/admin/models.py index 1048b3d0..89785772 100644 --- a/src/vr/admin/models.py +++ b/src/vr/admin/models.py @@ -416,6 +416,43 @@ class AppConfig(db.Model): __tablename__ = 'AppConfig' id = db.Column(db.Integer, primary_key=True) first_access = db.Column(db.Boolean, nullable=False, default=True) + settings_initialized = db.Column(db.Boolean, nullable=False, default=False) + APP_EXT_URL = db.Column(db.String(200)) + AUTH_TYPE = db.Column(db.String(200)) + AZAD_AUTHORITY = db.Column(db.String(200)) + AZAD_CLIENT_ID = db.Column(db.String(200)) + AZAD_CLIENT_SECRET = db.Column(db.String(200)) + AZURE_KEYVAULT_NAME = db.Column(db.String(200)) + ENV = db.Column(db.String(200)) + INSECURE_OAUTH = db.Column(db.String(200)) + JENKINS_HOST = db.Column(db.String(200)) + JENKINS_KEY = db.Column(db.String(200)) + JENKINS_PROJECT = db.Column(db.String(200)) + JENKINS_STAGING_PROJECT = db.Column(db.String(200)) + JENKINS_TOKEN = db.Column(db.String(200)) + JENKINS_USER = db.Column(db.String(200)) + LDAP_BASE_DN = db.Column(db.String(200)) + LDAP_BIND_USER_DN = db.Column(db.String(200)) + LDAP_BIND_USER_PASSWORD = db.Column(db.String(200)) + LDAP_GROUP_DN = db.Column(db.String(200)) + LDAP_HOST = db.Column(db.String(200)) + LDAP_PORT = db.Column(db.String(200)) + LDAP_USER_DN = db.Column(db.String(200)) + LDAP_USER_LOGIN_ATTR = db.Column(db.String(200)) + LDAP_USER_RDN_ATTR = db.Column(db.String(200)) + PROD_DB_URI = db.Column(db.String(200)) + SMTP_ADMIN_EMAIL = db.Column(db.String(200)) + SMTP_HOST = db.Column(db.String(200)) + SMTP_PASSWORD = db.Column(db.String(200)) + SMTP_USER = db.Column(db.String(200)) + SNOW_CLIENT_ID = db.Column(db.String(200)) + SNOW_CLIENT_SECRET = db.Column(db.String(200)) + SNOW_INSTANCE_NAME = db.Column(db.String(200)) + SNOW_PASSWORD = db.Column(db.String(200)) + SNOW_USERNAME = db.Column(db.String(200)) + VERSION = db.Column(db.String(200)) + JENKINS_ENABLED = db.Column(db.String(200)) + SNOW_ENABLED = db.Column(db.String(200)) class SuSiteConfiguration(db.Model): diff --git a/src/vr/admin/routes/settings.py b/src/vr/admin/routes/settings.py index c366ce43..a3125e54 100644 --- a/src/vr/admin/routes/settings.py +++ b/src/vr/admin/routes/settings.py @@ -1,4 +1,4 @@ -from flask import session, redirect, url_for, render_template +from flask import session, redirect, url_for, render_template, request from flask_login import login_required from vr import db, app import os @@ -10,14 +10,18 @@ AZAD_CLIENT_ID, AZAD_CLIENT_SECRET, AZAD_AUTHORITY, JENKINS_USER, AZURE_KEYVAULT_NAME, INSECURE_OAUTH, \ JENKINS_HOST, JENKINS_KEY, JENKINS_PROJECT, JENKINS_STAGING_PROJECT, JENKINS_TOKEN, SMTP_ADMIN_EMAIL, \ SMTP_HOST, SMTP_PASSWORD, SMTP_USER, SNOW_CLIENT_ID, SNOW_CLIENT_SECRET, SNOW_INSTANCE_NAME, SNOW_PASSWORD, \ - SNOW_USERNAME, VERSION + SNOW_USERNAME, VERSION, JENKINS_ENABLED, SNOW_ENABLED from flask_sqlalchemy import SQLAlchemy +from vr.admin.models import AppConfig +from vr.admin.functions import db_connection_handler +from sqlalchemy import text + NAV = { 'CAT': { "name": "Settings", "url": "admin.admin_dashboard"} } -@admin.route('/settings', methods=['GET']) +@admin.route('/settings', methods=['GET', 'POST']) @login_required def settings(): NAV['curpage'] = {"name": "Settings"} @@ -27,44 +31,263 @@ def settings(): elif status == 403: return render_template('403.html', user=user, nav_cat={}, nav_subcat='', \ nav_subsubcat='', nav_curpage={"name": "Unauthorized"}) - current_settings = { - "APP_EXT_URL": APP_EXT_URL, - "AUTH_TYPE": AUTH_TYPE, - "AZAD_AUTHORITY":AZAD_AUTHORITY, - "AZAD_CLIENT_ID": AZAD_CLIENT_ID, - "AZAD_CLIENT_SECRET": AZAD_CLIENT_SECRET, - "AZURE_KEYVAULT_NAME": AZURE_KEYVAULT_NAME, - "ENV": ENV, - "INSECURE_OAUTH": INSECURE_OAUTH, - "JENKINS_HOST": JENKINS_HOST, - "JENKINS_KEY": JENKINS_KEY, - "JENKINS_PROJECT": JENKINS_PROJECT, - "JENKINS_STAGING_PROJECT": JENKINS_STAGING_PROJECT, - "JENKINS_TOKEN": JENKINS_TOKEN, - "JENKINS_USER": JENKINS_USER, - "LDAP_BASE_DN": LDAP_BASE_DN, - "LDAP_BIND_USER_DN": LDAP_BIND_USER_DN, - "LDAP_BIND_USER_PASSWORD": LDAP_BIND_USER_PASSWORD, - "LDAP_GROUP_DN": LDAP_GROUP_DN, - "LDAP_HOST": LDAP_HOST, - "LDAP_PORT": LDAP_PORT, - "LDAP_USER_DN": LDAP_USER_DN, - "LDAP_USER_LOGIN_ATTR": LDAP_USER_LOGIN_ATTR, - "LDAP_USER_RDN_ATTR": LDAP_USER_RDN_ATTR, - "PROD_DB_URI": PROD_DB_URI, - "SMTP_ADMIN_EMAIL": SMTP_ADMIN_EMAIL, - "SMTP_HOST": SMTP_HOST, - "SMTP_PASSWORD": SMTP_PASSWORD, - "SMTP_USER": SMTP_USER, - "SNOW_CLIENT_ID": SNOW_CLIENT_ID, - "SNOW_CLIENT_SECRET": SNOW_CLIENT_SECRET, - "SNOW_INSTANCE_NAME": SNOW_INSTANCE_NAME, - "SNOW_PASSWORD": SNOW_PASSWORD, - "SNOW_USERNAME": SNOW_USERNAME, - "VERSION": VERSION, - } + if request.method == 'POST': + app_config = AppConfig.query.first() + + all = request.form + update_json = { + AppConfig.JENKINS_ENABLED: all["JENKINS_ENABLED"], + AppConfig.SNOW_ENABLED: all["SNOW_ENABLED"], + AppConfig.APP_EXT_URL: all["APP_EXT_URL"], + AppConfig.AUTH_TYPE: all["AUTH_TYPE"], + AppConfig.AZAD_AUTHORITY: all["AZAD_AUTHORITY"], + AppConfig.AZAD_CLIENT_ID: all["AZAD_CLIENT_ID"], + AppConfig.AZAD_CLIENT_SECRET: all["AZAD_CLIENT_SECRET"], + AppConfig.AZURE_KEYVAULT_NAME: all["AZURE_KEYVAULT_NAME"], + AppConfig.ENV: all["ENV"], + AppConfig.INSECURE_OAUTH: all["INSECURE_OAUTH"], + AppConfig.JENKINS_HOST: all["JENKINS_HOST"], + AppConfig.JENKINS_KEY: all["JENKINS_KEY"], + AppConfig.JENKINS_PROJECT: all["JENKINS_PROJECT"], + AppConfig.JENKINS_STAGING_PROJECT: all["JENKINS_STAGING_PROJECT"], + AppConfig.JENKINS_TOKEN: all["JENKINS_TOKEN"], + AppConfig.JENKINS_USER: all["JENKINS_USER"], + AppConfig.LDAP_BASE_DN: all["LDAP_BASE_DN"], + AppConfig.LDAP_BIND_USER_DN: all["LDAP_BIND_USER_DN"], + AppConfig.LDAP_BIND_USER_PASSWORD: all["LDAP_BIND_USER_PASSWORD"], + AppConfig.LDAP_GROUP_DN: all["LDAP_GROUP_DN"], + AppConfig.LDAP_HOST: all["LDAP_HOST"], + AppConfig.LDAP_PORT: all["LDAP_PORT"], + AppConfig.LDAP_USER_DN: all["LDAP_USER_DN"], + AppConfig.LDAP_USER_LOGIN_ATTR: all["LDAP_USER_LOGIN_ATTR"], + AppConfig.LDAP_USER_RDN_ATTR: all["LDAP_USER_RDN_ATTR"], + AppConfig.PROD_DB_URI: all["PROD_DB_URI"], + AppConfig.SMTP_ADMIN_EMAIL: all["SMTP_ADMIN_EMAIL"], + AppConfig.SMTP_HOST: all["SMTP_HOST"], + AppConfig.SMTP_PASSWORD: all["SMTP_PASSWORD"], + AppConfig.SMTP_USER: all["SMTP_USER"], + AppConfig.SNOW_CLIENT_ID: all["SNOW_CLIENT_ID"], + AppConfig.SNOW_CLIENT_SECRET: all["SNOW_CLIENT_SECRET"], + AppConfig.SNOW_INSTANCE_NAME: all["SNOW_INSTANCE_NAME"], + AppConfig.SNOW_PASSWORD: all["SNOW_PASSWORD"], + AppConfig.SNOW_USERNAME: all["SNOW_USERNAME"], + AppConfig.VERSION: all["VERSION"], + } + if not app_config.settings_initialized: + update_json[AppConfig.settings_initialized] = True + db.session.query(AppConfig) \ + .update(update_json, synchronize_session=False) + db_connection_handler(db) + set_env_variables(all) + current_settings = { + "JENKINS_ENABLED": all["JENKINS_ENABLED"], + "SNOW_ENABLED": all["SNOW_ENABLED"], + "APP_EXT_URL": all["APP_EXT_URL"], + "AUTH_TYPE": all["AUTH_TYPE"], + "AZAD_AUTHORITY": all["AZAD_AUTHORITY"], + "AZAD_CLIENT_ID": all["AZAD_CLIENT_ID"], + "AZAD_CLIENT_SECRET": all["AZAD_CLIENT_SECRET"], + "AZURE_KEYVAULT_NAME": all["AZURE_KEYVAULT_NAME"], + "ENV": all["ENV"], + "INSECURE_OAUTH": all["INSECURE_OAUTH"], + "JENKINS_HOST": all["JENKINS_HOST"], + "JENKINS_KEY": all["JENKINS_KEY"], + "JENKINS_PROJECT": all["JENKINS_PROJECT"], + "JENKINS_STAGING_PROJECT": all["JENKINS_STAGING_PROJECT"], + "JENKINS_TOKEN": all["JENKINS_TOKEN"], + "JENKINS_USER": all["JENKINS_USER"], + "LDAP_BASE_DN": all["LDAP_BASE_DN"], + "LDAP_BIND_USER_DN": all["LDAP_BIND_USER_DN"], + "LDAP_BIND_USER_PASSWORD": all["LDAP_BIND_USER_PASSWORD"], + "LDAP_GROUP_DN": all["LDAP_GROUP_DN"], + "LDAP_HOST": all["LDAP_HOST"], + "LDAP_PORT": all["LDAP_PORT"], + "LDAP_USER_DN": all["LDAP_USER_DN"], + "LDAP_USER_LOGIN_ATTR": all["LDAP_USER_LOGIN_ATTR"], + "LDAP_USER_RDN_ATTR": all["LDAP_USER_RDN_ATTR"], + "PROD_DB_URI": all["PROD_DB_URI"], + "SMTP_ADMIN_EMAIL": all["SMTP_ADMIN_EMAIL"], + "SMTP_HOST": all["SMTP_HOST"], + "SMTP_PASSWORD": all["SMTP_PASSWORD"], + "SMTP_USER": all["SMTP_USER"], + "SNOW_CLIENT_ID": all["SNOW_CLIENT_ID"], + "SNOW_CLIENT_SECRET": all["SNOW_CLIENT_SECRET"], + "SNOW_INSTANCE_NAME": all["SNOW_INSTANCE_NAME"], + "SNOW_PASSWORD": all["SNOW_PASSWORD"], + "SNOW_USERNAME": all["SNOW_USERNAME"], + "VERSION": all["VERSION"], + } + else: + app_config = AppConfig.query.first() + if app_config.settings_initialized: + current_settings = { + "JENKINS_ENABLED": app_config.JENKINS_ENABLED, + "SNOW_ENABLED": app_config.SNOW_ENABLED, + "APP_EXT_URL": app_config.APP_EXT_URL, + "AUTH_TYPE": app_config.AUTH_TYPE, + "AZAD_AUTHORITY": app_config.AZAD_AUTHORITY, + "AZAD_CLIENT_ID": app_config.AZAD_CLIENT_ID, + "AZAD_CLIENT_SECRET": app_config.AZAD_CLIENT_SECRET, + "AZURE_KEYVAULT_NAME": app_config.AZURE_KEYVAULT_NAME, + "ENV": app_config.ENV, + "INSECURE_OAUTH": app_config.INSECURE_OAUTH, + "JENKINS_HOST": app_config.JENKINS_HOST, + "JENKINS_KEY": app_config.JENKINS_KEY, + "JENKINS_PROJECT": app_config.JENKINS_PROJECT, + "JENKINS_STAGING_PROJECT": app_config.JENKINS_STAGING_PROJECT, + "JENKINS_USER": app_config.JENKINS_USER, + "JENKINS_TOKEN": app_config.JENKINS_TOKEN, + "LDAP_BASE_DN": app_config.LDAP_BASE_DN, + "LDAP_BIND_USER_DN": app_config.LDAP_BIND_USER_DN, + "LDAP_BIND_USER_PASSWORD": app_config.LDAP_BIND_USER_PASSWORD, + "LDAP_GROUP_DN": app_config.LDAP_GROUP_DN, + "LDAP_HOST": app_config.LDAP_HOST, + "LDAP_PORT": app_config.LDAP_PORT, + "LDAP_USER_DN": app_config.LDAP_USER_DN, + "LDAP_USER_LOGIN_ATTR": app_config.LDAP_USER_LOGIN_ATTR, + "LDAP_USER_RDN_ATTR": app_config.LDAP_USER_RDN_ATTR, + "PROD_DB_URI": app_config.PROD_DB_URI, + "SMTP_ADMIN_EMAIL": app_config.SMTP_ADMIN_EMAIL, + "SMTP_HOST": app_config.SMTP_HOST, + "SMTP_USER": app_config.SMTP_USER, + "SMTP_PASSWORD": app_config.SMTP_PASSWORD, + "SNOW_CLIENT_ID": app_config.SNOW_CLIENT_ID, + "SNOW_CLIENT_SECRET": app_config.SNOW_CLIENT_SECRET, + "SNOW_INSTANCE_NAME": app_config.SNOW_INSTANCE_NAME, + "SNOW_USERNAME": app_config.SNOW_USERNAME, + "SNOW_PASSWORD": app_config.SNOW_PASSWORD, + "VERSION": app_config.VERSION, + } + else: + current_settings = { + "JENKINS_ENABLED": JENKINS_ENABLED, + "SNOW_ENABLED": SNOW_ENABLED, + "APP_EXT_URL": APP_EXT_URL, + "AUTH_TYPE": AUTH_TYPE, + "AZAD_AUTHORITY":AZAD_AUTHORITY, + "AZAD_CLIENT_ID": AZAD_CLIENT_ID, + "AZAD_CLIENT_SECRET": AZAD_CLIENT_SECRET, + "AZURE_KEYVAULT_NAME": AZURE_KEYVAULT_NAME, + "ENV": ENV, + "INSECURE_OAUTH": INSECURE_OAUTH, + "JENKINS_HOST": JENKINS_HOST, + "JENKINS_KEY": JENKINS_KEY, + "JENKINS_PROJECT": JENKINS_PROJECT, + "JENKINS_STAGING_PROJECT": JENKINS_STAGING_PROJECT, + "JENKINS_USER": JENKINS_USER, + "JENKINS_TOKEN": JENKINS_TOKEN, + "LDAP_BASE_DN": LDAP_BASE_DN, + "LDAP_BIND_USER_DN": LDAP_BIND_USER_DN, + "LDAP_BIND_USER_PASSWORD": LDAP_BIND_USER_PASSWORD, + "LDAP_GROUP_DN": LDAP_GROUP_DN, + "LDAP_HOST": LDAP_HOST, + "LDAP_PORT": LDAP_PORT, + "LDAP_USER_DN": LDAP_USER_DN, + "LDAP_USER_LOGIN_ATTR": LDAP_USER_LOGIN_ATTR, + "LDAP_USER_RDN_ATTR": LDAP_USER_RDN_ATTR, + "PROD_DB_URI": PROD_DB_URI, + "SMTP_ADMIN_EMAIL": SMTP_ADMIN_EMAIL, + "SMTP_HOST": SMTP_HOST, + "SMTP_USER": SMTP_USER, + "SMTP_PASSWORD": SMTP_PASSWORD, + "SNOW_CLIENT_ID": SNOW_CLIENT_ID, + "SNOW_CLIENT_SECRET": SNOW_CLIENT_SECRET, + "SNOW_INSTANCE_NAME": SNOW_INSTANCE_NAME, + "SNOW_USERNAME": SNOW_USERNAME, + "SNOW_PASSWORD": SNOW_PASSWORD, + "VERSION": VERSION, + } + cat_general = [ + 'APP_EXT_URL', + 'AUTH_TYPE', + 'ENV', + 'INSECURE_OAUTH', + 'PROD_DB_URI', + 'VERSION', + 'AZURE_KEYVAULT_NAME' + ] + cat_azad = [ + 'AZAD_AUTHORITY', + 'AZAD_CLIENT_ID', + 'AZAD_CLIENT_SECRET' + ] + cat_jenkins = [ + 'JENKINS_ENABLED', + 'JENKINS_HOST', + 'JENKINS_KEY', + 'JENKINS_PROJECT', + 'JENKINS_STAGING_PROJECT', + 'JENKINS_TOKEN', + 'JENKINS_USER' + ] + cat_ldap = [ + 'LDAP_BASE_DN', + 'LDAP_BIND_USER_DN', + 'LDAP_BIND_USER_PASSWORD', + 'LDAP_GROUP_DN', + 'LDAP_HOST', + 'LDAP_PORT', + 'LDAP_USER_DN', + 'LDAP_USER_LOGIN_ATTR', + 'LDAP_USER_RDN_ATTR' + ] + smtp_settings = [ + 'SMTP_ADMIN_EMAIL', + 'SMTP_HOST', + 'SMTP_PASSWORD', + 'SMTP_USER' + ] + snow_settings = [ + 'SNOW_ENABLED', + 'SNOW_CLIENT_ID', + 'SNOW_CLIENT_SECRET', + 'SNOW_INSTANCE_NAME', + 'SNOW_PASSWORD', + 'SNOW_USERNAME' + ] return render_template('admin/settings.html', user_roles=user_roles, NAV=NAV, - user=user, settings=current_settings) + user=user, settings=current_settings, cat_general=cat_general, + cat_azad=cat_azad, cat_jenkins=cat_jenkins, cat_ldap=cat_ldap, + smtp_settings=smtp_settings, snow_settings=snow_settings) + +def set_env_variables(form): + os.environ['APP_EXT_URL'] = form["APP_EXT_URL"] + os.environ['AUTH_TYPE'] = form["AUTH_TYPE"] + os.environ['AZAD_AUTHORITY'] = form["AZAD_AUTHORITY"] + os.environ['AZAD_CLIENT_ID'] = form["AZAD_CLIENT_ID"] + os.environ['AZAD_CLIENT_SECRET'] = form["AZAD_CLIENT_SECRET"] + os.environ['AZURE_KEYVAULT_NAME'] = form["AZURE_KEYVAULT_NAME"] + os.environ['ENV'] = form["ENV"] + os.environ['INSECURE_OAUTH'] = form["INSECURE_OAUTH"] + os.environ['JENKINS_ENABLED'] = form["JENKINS_ENABLED"] + os.environ['JENKINS_HOST'] = form["JENKINS_HOST"] + os.environ['JENKINS_KEY'] = form["JENKINS_KEY"] + os.environ['JENKINS_PROJECT'] = form["JENKINS_PROJECT"] + os.environ['JENKINS_STAGING_PROJECT'] = form["JENKINS_STAGING_PROJECT"] + os.environ['JENKINS_TOKEN'] = form["JENKINS_TOKEN"] + os.environ['JENKINS_USER'] = form["JENKINS_USER"] + os.environ['LDAP_BASE_DN'] = form["LDAP_BASE_DN"] + os.environ['LDAP_BIND_USER_DN'] = form["LDAP_BIND_USER_DN"] + os.environ['LDAP_BIND_USER_PASSWORD'] = form["LDAP_BIND_USER_PASSWORD"] + os.environ['LDAP_GROUP_DN'] = form["LDAP_GROUP_DN"] + os.environ['LDAP_HOST'] = form["LDAP_HOST"] + os.environ['LDAP_PORT'] = form["LDAP_PORT"] + os.environ['LDAP_USER_DN'] = form["LDAP_USER_DN"] + os.environ['LDAP_USER_LOGIN_ATTR'] = form["LDAP_USER_LOGIN_ATTR"] + os.environ['LDAP_USER_RDN_ATTR'] = form["LDAP_USER_RDN_ATTR"] + os.environ['PROD_DB_URI'] = form["PROD_DB_URI"] + os.environ['SMTP_ADMIN_EMAIL'] = form["SMTP_ADMIN_EMAIL"] + os.environ['SMTP_HOST'] = form["SMTP_HOST"] + os.environ['SMTP_PASSWORD'] = form["SMTP_PASSWORD"] + os.environ['SMTP_USER'] = form["SMTP_USER"] + os.environ['SNOW_ENABLED'] = form["SNOW_ENABLED"] + os.environ['SNOW_CLIENT_ID'] = form["SNOW_CLIENT_ID"] + os.environ['SNOW_CLIENT_SECRET'] = form["SNOW_CLIENT_SECRET"] + os.environ['SNOW_INSTANCE_NAME'] = form["SNOW_INSTANCE_NAME"] + os.environ['SNOW_PASSWORD'] = form["SNOW_PASSWORD"] + os.environ['SNOW_USERNAME'] = form["SNOW_USERNAME"] + os.environ['VERSION'] = form["VERSION"] + @admin.route('/dangerous/delete_all', methods=['POST']) def delete_all_data(): diff --git a/src/vr/db_models/setup.py b/src/vr/db_models/setup.py index 67adfc3b..b36fdc22 100644 --- a/src/vr/db_models/setup.py +++ b/src/vr/db_models/setup.py @@ -117,6 +117,43 @@ class AppConfig(db.Model): __table_args__ = {'extend_existing': True} id = db.Column(db.Integer, primary_key=True) first_access = db.Column(db.Boolean, nullable=False, default=True) + settings_initialized = db.Column(db.Boolean, nullable=False, default=False) + APP_EXT_URL = db.Column(db.String(200)) + AUTH_TYPE = db.Column(db.String(200)) + AZAD_AUTHORITY = db.Column(db.String(200)) + AZAD_CLIENT_ID = db.Column(db.String(200)) + AZAD_CLIENT_SECRET = db.Column(db.String(200)) + AZURE_KEYVAULT_NAME = db.Column(db.String(200)) + ENV = db.Column(db.String(200)) + INSECURE_OAUTH = db.Column(db.String(200)) + JENKINS_HOST = db.Column(db.String(200)) + JENKINS_KEY = db.Column(db.String(200)) + JENKINS_PROJECT = db.Column(db.String(200)) + JENKINS_STAGING_PROJECT = db.Column(db.String(200)) + JENKINS_TOKEN = db.Column(db.String(200)) + JENKINS_USER = db.Column(db.String(200)) + LDAP_BASE_DN = db.Column(db.String(200)) + LDAP_BIND_USER_DN = db.Column(db.String(200)) + LDAP_BIND_USER_PASSWORD = db.Column(db.String(200)) + LDAP_GROUP_DN = db.Column(db.String(200)) + LDAP_HOST = db.Column(db.String(200)) + LDAP_PORT = db.Column(db.String(200)) + LDAP_USER_DN = db.Column(db.String(200)) + LDAP_USER_LOGIN_ATTR = db.Column(db.String(200)) + LDAP_USER_RDN_ATTR = db.Column(db.String(200)) + PROD_DB_URI = db.Column(db.String(200)) + SMTP_ADMIN_EMAIL = db.Column(db.String(200)) + SMTP_HOST = db.Column(db.String(200)) + SMTP_PASSWORD = db.Column(db.String(200)) + SMTP_USER = db.Column(db.String(200)) + SNOW_CLIENT_ID = db.Column(db.String(200)) + SNOW_CLIENT_SECRET = db.Column(db.String(200)) + SNOW_INSTANCE_NAME = db.Column(db.String(200)) + SNOW_PASSWORD = db.Column(db.String(200)) + SNOW_USERNAME = db.Column(db.String(200)) + VERSION = db.Column(db.String(200)) + JENKINS_ENABLED = db.Column(db.String(200)) + SNOW_ENABLED = db.Column(db.String(200)) AppConfig() diff --git a/src/vr/templates/admin/settings.html b/src/vr/templates/admin/settings.html index 06a4bee5..a7564e1a 100644 --- a/src/vr/templates/admin/settings.html +++ b/src/vr/templates/admin/settings.html @@ -113,13 +113,135 @@

Application Settings

+ + +
+

General Settings

+ {% for key, value in settings.items() %} + {% if key in cat_general %} +
+ + {% if key == "AUTH_TYPE" %} + + {% elif key == "INSECURE_OAUTH" %} + + {% elif key == "PROD_DB_URI" %} +
+ {% elif key == "ENV" or key == "VERSION" %} + + {% else %} + + {% endif %} +
+ {% endif %} + {% endfor %} +
+ +
+

LDAP Settings

{% for key, value in settings.items() %} -
- - + {% if key in cat_ldap %} +
+ + +
+ {% endif %} + {% endfor %}
+ +
+

Azure Active Directory Settings

+ {% for key, value in settings.items() %} + {% if key in cat_azad %} +
+ + +
+ {% endif %} {% endfor %} +
+ +
+

SMTP Settings

+ {% for key, value in settings.items() %} + {% if key in smtp_settings %} +
+ + {% if key == 'SMTP_PASSWORD' %} +
+ {% else %} + + {% endif %} + +
+ {% endif %} + {% endfor %} +
+ +
+

Jenkins Settings

+ {% for key, value in settings.items() %} + {% if key in cat_jenkins %} +
+ {% if key == 'JENKINS_ENABLED' %} + + + {% elif key == 'JENKINS_KEY' %} + +
+ {% elif key == 'JENKINS_TOKEN' %} + +
+ {% else %} + + + {% endif %} +
+ {% endif %} + {% endfor %} +
+ + + + + +
+

ServiceNOW Settings

+ {% for key, value in settings.items() %} + {% if key in snow_settings %} +
+ {% if key == 'SNOW_ENABLED' %} + + + {% elif key == 'SNOW_CLIENT_SECRET' %} + +
+ {% elif key == 'SNOW_PASSWORD' %} + +
+ {% else %} + + + {% endif %} +
+ {% endif %} + {% endfor %} +
+
@@ -128,4 +250,157 @@

Application Settings

+ + {% endblock %} From e5d9602e91cd7f22a21e78682dcdcd8af8c1ddbe Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sun, 17 Mar 2024 18:22:25 -0700 Subject: [PATCH 053/197] Release/0.1.0 beta/prod azure (#502) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile * Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * Feature/update settings function (#501) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups --- src/vr/admin/models.py | 37 ++++ src/vr/admin/routes/settings.py | 303 +++++++++++++++++++++++---- src/vr/db_models/setup.py | 37 ++++ src/vr/templates/admin/settings.html | 281 ++++++++++++++++++++++++- 4 files changed, 615 insertions(+), 43 deletions(-) diff --git a/src/vr/admin/models.py b/src/vr/admin/models.py index 1048b3d0..89785772 100644 --- a/src/vr/admin/models.py +++ b/src/vr/admin/models.py @@ -416,6 +416,43 @@ class AppConfig(db.Model): __tablename__ = 'AppConfig' id = db.Column(db.Integer, primary_key=True) first_access = db.Column(db.Boolean, nullable=False, default=True) + settings_initialized = db.Column(db.Boolean, nullable=False, default=False) + APP_EXT_URL = db.Column(db.String(200)) + AUTH_TYPE = db.Column(db.String(200)) + AZAD_AUTHORITY = db.Column(db.String(200)) + AZAD_CLIENT_ID = db.Column(db.String(200)) + AZAD_CLIENT_SECRET = db.Column(db.String(200)) + AZURE_KEYVAULT_NAME = db.Column(db.String(200)) + ENV = db.Column(db.String(200)) + INSECURE_OAUTH = db.Column(db.String(200)) + JENKINS_HOST = db.Column(db.String(200)) + JENKINS_KEY = db.Column(db.String(200)) + JENKINS_PROJECT = db.Column(db.String(200)) + JENKINS_STAGING_PROJECT = db.Column(db.String(200)) + JENKINS_TOKEN = db.Column(db.String(200)) + JENKINS_USER = db.Column(db.String(200)) + LDAP_BASE_DN = db.Column(db.String(200)) + LDAP_BIND_USER_DN = db.Column(db.String(200)) + LDAP_BIND_USER_PASSWORD = db.Column(db.String(200)) + LDAP_GROUP_DN = db.Column(db.String(200)) + LDAP_HOST = db.Column(db.String(200)) + LDAP_PORT = db.Column(db.String(200)) + LDAP_USER_DN = db.Column(db.String(200)) + LDAP_USER_LOGIN_ATTR = db.Column(db.String(200)) + LDAP_USER_RDN_ATTR = db.Column(db.String(200)) + PROD_DB_URI = db.Column(db.String(200)) + SMTP_ADMIN_EMAIL = db.Column(db.String(200)) + SMTP_HOST = db.Column(db.String(200)) + SMTP_PASSWORD = db.Column(db.String(200)) + SMTP_USER = db.Column(db.String(200)) + SNOW_CLIENT_ID = db.Column(db.String(200)) + SNOW_CLIENT_SECRET = db.Column(db.String(200)) + SNOW_INSTANCE_NAME = db.Column(db.String(200)) + SNOW_PASSWORD = db.Column(db.String(200)) + SNOW_USERNAME = db.Column(db.String(200)) + VERSION = db.Column(db.String(200)) + JENKINS_ENABLED = db.Column(db.String(200)) + SNOW_ENABLED = db.Column(db.String(200)) class SuSiteConfiguration(db.Model): diff --git a/src/vr/admin/routes/settings.py b/src/vr/admin/routes/settings.py index c366ce43..a3125e54 100644 --- a/src/vr/admin/routes/settings.py +++ b/src/vr/admin/routes/settings.py @@ -1,4 +1,4 @@ -from flask import session, redirect, url_for, render_template +from flask import session, redirect, url_for, render_template, request from flask_login import login_required from vr import db, app import os @@ -10,14 +10,18 @@ AZAD_CLIENT_ID, AZAD_CLIENT_SECRET, AZAD_AUTHORITY, JENKINS_USER, AZURE_KEYVAULT_NAME, INSECURE_OAUTH, \ JENKINS_HOST, JENKINS_KEY, JENKINS_PROJECT, JENKINS_STAGING_PROJECT, JENKINS_TOKEN, SMTP_ADMIN_EMAIL, \ SMTP_HOST, SMTP_PASSWORD, SMTP_USER, SNOW_CLIENT_ID, SNOW_CLIENT_SECRET, SNOW_INSTANCE_NAME, SNOW_PASSWORD, \ - SNOW_USERNAME, VERSION + SNOW_USERNAME, VERSION, JENKINS_ENABLED, SNOW_ENABLED from flask_sqlalchemy import SQLAlchemy +from vr.admin.models import AppConfig +from vr.admin.functions import db_connection_handler +from sqlalchemy import text + NAV = { 'CAT': { "name": "Settings", "url": "admin.admin_dashboard"} } -@admin.route('/settings', methods=['GET']) +@admin.route('/settings', methods=['GET', 'POST']) @login_required def settings(): NAV['curpage'] = {"name": "Settings"} @@ -27,44 +31,263 @@ def settings(): elif status == 403: return render_template('403.html', user=user, nav_cat={}, nav_subcat='', \ nav_subsubcat='', nav_curpage={"name": "Unauthorized"}) - current_settings = { - "APP_EXT_URL": APP_EXT_URL, - "AUTH_TYPE": AUTH_TYPE, - "AZAD_AUTHORITY":AZAD_AUTHORITY, - "AZAD_CLIENT_ID": AZAD_CLIENT_ID, - "AZAD_CLIENT_SECRET": AZAD_CLIENT_SECRET, - "AZURE_KEYVAULT_NAME": AZURE_KEYVAULT_NAME, - "ENV": ENV, - "INSECURE_OAUTH": INSECURE_OAUTH, - "JENKINS_HOST": JENKINS_HOST, - "JENKINS_KEY": JENKINS_KEY, - "JENKINS_PROJECT": JENKINS_PROJECT, - "JENKINS_STAGING_PROJECT": JENKINS_STAGING_PROJECT, - "JENKINS_TOKEN": JENKINS_TOKEN, - "JENKINS_USER": JENKINS_USER, - "LDAP_BASE_DN": LDAP_BASE_DN, - "LDAP_BIND_USER_DN": LDAP_BIND_USER_DN, - "LDAP_BIND_USER_PASSWORD": LDAP_BIND_USER_PASSWORD, - "LDAP_GROUP_DN": LDAP_GROUP_DN, - "LDAP_HOST": LDAP_HOST, - "LDAP_PORT": LDAP_PORT, - "LDAP_USER_DN": LDAP_USER_DN, - "LDAP_USER_LOGIN_ATTR": LDAP_USER_LOGIN_ATTR, - "LDAP_USER_RDN_ATTR": LDAP_USER_RDN_ATTR, - "PROD_DB_URI": PROD_DB_URI, - "SMTP_ADMIN_EMAIL": SMTP_ADMIN_EMAIL, - "SMTP_HOST": SMTP_HOST, - "SMTP_PASSWORD": SMTP_PASSWORD, - "SMTP_USER": SMTP_USER, - "SNOW_CLIENT_ID": SNOW_CLIENT_ID, - "SNOW_CLIENT_SECRET": SNOW_CLIENT_SECRET, - "SNOW_INSTANCE_NAME": SNOW_INSTANCE_NAME, - "SNOW_PASSWORD": SNOW_PASSWORD, - "SNOW_USERNAME": SNOW_USERNAME, - "VERSION": VERSION, - } + if request.method == 'POST': + app_config = AppConfig.query.first() + + all = request.form + update_json = { + AppConfig.JENKINS_ENABLED: all["JENKINS_ENABLED"], + AppConfig.SNOW_ENABLED: all["SNOW_ENABLED"], + AppConfig.APP_EXT_URL: all["APP_EXT_URL"], + AppConfig.AUTH_TYPE: all["AUTH_TYPE"], + AppConfig.AZAD_AUTHORITY: all["AZAD_AUTHORITY"], + AppConfig.AZAD_CLIENT_ID: all["AZAD_CLIENT_ID"], + AppConfig.AZAD_CLIENT_SECRET: all["AZAD_CLIENT_SECRET"], + AppConfig.AZURE_KEYVAULT_NAME: all["AZURE_KEYVAULT_NAME"], + AppConfig.ENV: all["ENV"], + AppConfig.INSECURE_OAUTH: all["INSECURE_OAUTH"], + AppConfig.JENKINS_HOST: all["JENKINS_HOST"], + AppConfig.JENKINS_KEY: all["JENKINS_KEY"], + AppConfig.JENKINS_PROJECT: all["JENKINS_PROJECT"], + AppConfig.JENKINS_STAGING_PROJECT: all["JENKINS_STAGING_PROJECT"], + AppConfig.JENKINS_TOKEN: all["JENKINS_TOKEN"], + AppConfig.JENKINS_USER: all["JENKINS_USER"], + AppConfig.LDAP_BASE_DN: all["LDAP_BASE_DN"], + AppConfig.LDAP_BIND_USER_DN: all["LDAP_BIND_USER_DN"], + AppConfig.LDAP_BIND_USER_PASSWORD: all["LDAP_BIND_USER_PASSWORD"], + AppConfig.LDAP_GROUP_DN: all["LDAP_GROUP_DN"], + AppConfig.LDAP_HOST: all["LDAP_HOST"], + AppConfig.LDAP_PORT: all["LDAP_PORT"], + AppConfig.LDAP_USER_DN: all["LDAP_USER_DN"], + AppConfig.LDAP_USER_LOGIN_ATTR: all["LDAP_USER_LOGIN_ATTR"], + AppConfig.LDAP_USER_RDN_ATTR: all["LDAP_USER_RDN_ATTR"], + AppConfig.PROD_DB_URI: all["PROD_DB_URI"], + AppConfig.SMTP_ADMIN_EMAIL: all["SMTP_ADMIN_EMAIL"], + AppConfig.SMTP_HOST: all["SMTP_HOST"], + AppConfig.SMTP_PASSWORD: all["SMTP_PASSWORD"], + AppConfig.SMTP_USER: all["SMTP_USER"], + AppConfig.SNOW_CLIENT_ID: all["SNOW_CLIENT_ID"], + AppConfig.SNOW_CLIENT_SECRET: all["SNOW_CLIENT_SECRET"], + AppConfig.SNOW_INSTANCE_NAME: all["SNOW_INSTANCE_NAME"], + AppConfig.SNOW_PASSWORD: all["SNOW_PASSWORD"], + AppConfig.SNOW_USERNAME: all["SNOW_USERNAME"], + AppConfig.VERSION: all["VERSION"], + } + if not app_config.settings_initialized: + update_json[AppConfig.settings_initialized] = True + db.session.query(AppConfig) \ + .update(update_json, synchronize_session=False) + db_connection_handler(db) + set_env_variables(all) + current_settings = { + "JENKINS_ENABLED": all["JENKINS_ENABLED"], + "SNOW_ENABLED": all["SNOW_ENABLED"], + "APP_EXT_URL": all["APP_EXT_URL"], + "AUTH_TYPE": all["AUTH_TYPE"], + "AZAD_AUTHORITY": all["AZAD_AUTHORITY"], + "AZAD_CLIENT_ID": all["AZAD_CLIENT_ID"], + "AZAD_CLIENT_SECRET": all["AZAD_CLIENT_SECRET"], + "AZURE_KEYVAULT_NAME": all["AZURE_KEYVAULT_NAME"], + "ENV": all["ENV"], + "INSECURE_OAUTH": all["INSECURE_OAUTH"], + "JENKINS_HOST": all["JENKINS_HOST"], + "JENKINS_KEY": all["JENKINS_KEY"], + "JENKINS_PROJECT": all["JENKINS_PROJECT"], + "JENKINS_STAGING_PROJECT": all["JENKINS_STAGING_PROJECT"], + "JENKINS_TOKEN": all["JENKINS_TOKEN"], + "JENKINS_USER": all["JENKINS_USER"], + "LDAP_BASE_DN": all["LDAP_BASE_DN"], + "LDAP_BIND_USER_DN": all["LDAP_BIND_USER_DN"], + "LDAP_BIND_USER_PASSWORD": all["LDAP_BIND_USER_PASSWORD"], + "LDAP_GROUP_DN": all["LDAP_GROUP_DN"], + "LDAP_HOST": all["LDAP_HOST"], + "LDAP_PORT": all["LDAP_PORT"], + "LDAP_USER_DN": all["LDAP_USER_DN"], + "LDAP_USER_LOGIN_ATTR": all["LDAP_USER_LOGIN_ATTR"], + "LDAP_USER_RDN_ATTR": all["LDAP_USER_RDN_ATTR"], + "PROD_DB_URI": all["PROD_DB_URI"], + "SMTP_ADMIN_EMAIL": all["SMTP_ADMIN_EMAIL"], + "SMTP_HOST": all["SMTP_HOST"], + "SMTP_PASSWORD": all["SMTP_PASSWORD"], + "SMTP_USER": all["SMTP_USER"], + "SNOW_CLIENT_ID": all["SNOW_CLIENT_ID"], + "SNOW_CLIENT_SECRET": all["SNOW_CLIENT_SECRET"], + "SNOW_INSTANCE_NAME": all["SNOW_INSTANCE_NAME"], + "SNOW_PASSWORD": all["SNOW_PASSWORD"], + "SNOW_USERNAME": all["SNOW_USERNAME"], + "VERSION": all["VERSION"], + } + else: + app_config = AppConfig.query.first() + if app_config.settings_initialized: + current_settings = { + "JENKINS_ENABLED": app_config.JENKINS_ENABLED, + "SNOW_ENABLED": app_config.SNOW_ENABLED, + "APP_EXT_URL": app_config.APP_EXT_URL, + "AUTH_TYPE": app_config.AUTH_TYPE, + "AZAD_AUTHORITY": app_config.AZAD_AUTHORITY, + "AZAD_CLIENT_ID": app_config.AZAD_CLIENT_ID, + "AZAD_CLIENT_SECRET": app_config.AZAD_CLIENT_SECRET, + "AZURE_KEYVAULT_NAME": app_config.AZURE_KEYVAULT_NAME, + "ENV": app_config.ENV, + "INSECURE_OAUTH": app_config.INSECURE_OAUTH, + "JENKINS_HOST": app_config.JENKINS_HOST, + "JENKINS_KEY": app_config.JENKINS_KEY, + "JENKINS_PROJECT": app_config.JENKINS_PROJECT, + "JENKINS_STAGING_PROJECT": app_config.JENKINS_STAGING_PROJECT, + "JENKINS_USER": app_config.JENKINS_USER, + "JENKINS_TOKEN": app_config.JENKINS_TOKEN, + "LDAP_BASE_DN": app_config.LDAP_BASE_DN, + "LDAP_BIND_USER_DN": app_config.LDAP_BIND_USER_DN, + "LDAP_BIND_USER_PASSWORD": app_config.LDAP_BIND_USER_PASSWORD, + "LDAP_GROUP_DN": app_config.LDAP_GROUP_DN, + "LDAP_HOST": app_config.LDAP_HOST, + "LDAP_PORT": app_config.LDAP_PORT, + "LDAP_USER_DN": app_config.LDAP_USER_DN, + "LDAP_USER_LOGIN_ATTR": app_config.LDAP_USER_LOGIN_ATTR, + "LDAP_USER_RDN_ATTR": app_config.LDAP_USER_RDN_ATTR, + "PROD_DB_URI": app_config.PROD_DB_URI, + "SMTP_ADMIN_EMAIL": app_config.SMTP_ADMIN_EMAIL, + "SMTP_HOST": app_config.SMTP_HOST, + "SMTP_USER": app_config.SMTP_USER, + "SMTP_PASSWORD": app_config.SMTP_PASSWORD, + "SNOW_CLIENT_ID": app_config.SNOW_CLIENT_ID, + "SNOW_CLIENT_SECRET": app_config.SNOW_CLIENT_SECRET, + "SNOW_INSTANCE_NAME": app_config.SNOW_INSTANCE_NAME, + "SNOW_USERNAME": app_config.SNOW_USERNAME, + "SNOW_PASSWORD": app_config.SNOW_PASSWORD, + "VERSION": app_config.VERSION, + } + else: + current_settings = { + "JENKINS_ENABLED": JENKINS_ENABLED, + "SNOW_ENABLED": SNOW_ENABLED, + "APP_EXT_URL": APP_EXT_URL, + "AUTH_TYPE": AUTH_TYPE, + "AZAD_AUTHORITY":AZAD_AUTHORITY, + "AZAD_CLIENT_ID": AZAD_CLIENT_ID, + "AZAD_CLIENT_SECRET": AZAD_CLIENT_SECRET, + "AZURE_KEYVAULT_NAME": AZURE_KEYVAULT_NAME, + "ENV": ENV, + "INSECURE_OAUTH": INSECURE_OAUTH, + "JENKINS_HOST": JENKINS_HOST, + "JENKINS_KEY": JENKINS_KEY, + "JENKINS_PROJECT": JENKINS_PROJECT, + "JENKINS_STAGING_PROJECT": JENKINS_STAGING_PROJECT, + "JENKINS_USER": JENKINS_USER, + "JENKINS_TOKEN": JENKINS_TOKEN, + "LDAP_BASE_DN": LDAP_BASE_DN, + "LDAP_BIND_USER_DN": LDAP_BIND_USER_DN, + "LDAP_BIND_USER_PASSWORD": LDAP_BIND_USER_PASSWORD, + "LDAP_GROUP_DN": LDAP_GROUP_DN, + "LDAP_HOST": LDAP_HOST, + "LDAP_PORT": LDAP_PORT, + "LDAP_USER_DN": LDAP_USER_DN, + "LDAP_USER_LOGIN_ATTR": LDAP_USER_LOGIN_ATTR, + "LDAP_USER_RDN_ATTR": LDAP_USER_RDN_ATTR, + "PROD_DB_URI": PROD_DB_URI, + "SMTP_ADMIN_EMAIL": SMTP_ADMIN_EMAIL, + "SMTP_HOST": SMTP_HOST, + "SMTP_USER": SMTP_USER, + "SMTP_PASSWORD": SMTP_PASSWORD, + "SNOW_CLIENT_ID": SNOW_CLIENT_ID, + "SNOW_CLIENT_SECRET": SNOW_CLIENT_SECRET, + "SNOW_INSTANCE_NAME": SNOW_INSTANCE_NAME, + "SNOW_USERNAME": SNOW_USERNAME, + "SNOW_PASSWORD": SNOW_PASSWORD, + "VERSION": VERSION, + } + cat_general = [ + 'APP_EXT_URL', + 'AUTH_TYPE', + 'ENV', + 'INSECURE_OAUTH', + 'PROD_DB_URI', + 'VERSION', + 'AZURE_KEYVAULT_NAME' + ] + cat_azad = [ + 'AZAD_AUTHORITY', + 'AZAD_CLIENT_ID', + 'AZAD_CLIENT_SECRET' + ] + cat_jenkins = [ + 'JENKINS_ENABLED', + 'JENKINS_HOST', + 'JENKINS_KEY', + 'JENKINS_PROJECT', + 'JENKINS_STAGING_PROJECT', + 'JENKINS_TOKEN', + 'JENKINS_USER' + ] + cat_ldap = [ + 'LDAP_BASE_DN', + 'LDAP_BIND_USER_DN', + 'LDAP_BIND_USER_PASSWORD', + 'LDAP_GROUP_DN', + 'LDAP_HOST', + 'LDAP_PORT', + 'LDAP_USER_DN', + 'LDAP_USER_LOGIN_ATTR', + 'LDAP_USER_RDN_ATTR' + ] + smtp_settings = [ + 'SMTP_ADMIN_EMAIL', + 'SMTP_HOST', + 'SMTP_PASSWORD', + 'SMTP_USER' + ] + snow_settings = [ + 'SNOW_ENABLED', + 'SNOW_CLIENT_ID', + 'SNOW_CLIENT_SECRET', + 'SNOW_INSTANCE_NAME', + 'SNOW_PASSWORD', + 'SNOW_USERNAME' + ] return render_template('admin/settings.html', user_roles=user_roles, NAV=NAV, - user=user, settings=current_settings) + user=user, settings=current_settings, cat_general=cat_general, + cat_azad=cat_azad, cat_jenkins=cat_jenkins, cat_ldap=cat_ldap, + smtp_settings=smtp_settings, snow_settings=snow_settings) + +def set_env_variables(form): + os.environ['APP_EXT_URL'] = form["APP_EXT_URL"] + os.environ['AUTH_TYPE'] = form["AUTH_TYPE"] + os.environ['AZAD_AUTHORITY'] = form["AZAD_AUTHORITY"] + os.environ['AZAD_CLIENT_ID'] = form["AZAD_CLIENT_ID"] + os.environ['AZAD_CLIENT_SECRET'] = form["AZAD_CLIENT_SECRET"] + os.environ['AZURE_KEYVAULT_NAME'] = form["AZURE_KEYVAULT_NAME"] + os.environ['ENV'] = form["ENV"] + os.environ['INSECURE_OAUTH'] = form["INSECURE_OAUTH"] + os.environ['JENKINS_ENABLED'] = form["JENKINS_ENABLED"] + os.environ['JENKINS_HOST'] = form["JENKINS_HOST"] + os.environ['JENKINS_KEY'] = form["JENKINS_KEY"] + os.environ['JENKINS_PROJECT'] = form["JENKINS_PROJECT"] + os.environ['JENKINS_STAGING_PROJECT'] = form["JENKINS_STAGING_PROJECT"] + os.environ['JENKINS_TOKEN'] = form["JENKINS_TOKEN"] + os.environ['JENKINS_USER'] = form["JENKINS_USER"] + os.environ['LDAP_BASE_DN'] = form["LDAP_BASE_DN"] + os.environ['LDAP_BIND_USER_DN'] = form["LDAP_BIND_USER_DN"] + os.environ['LDAP_BIND_USER_PASSWORD'] = form["LDAP_BIND_USER_PASSWORD"] + os.environ['LDAP_GROUP_DN'] = form["LDAP_GROUP_DN"] + os.environ['LDAP_HOST'] = form["LDAP_HOST"] + os.environ['LDAP_PORT'] = form["LDAP_PORT"] + os.environ['LDAP_USER_DN'] = form["LDAP_USER_DN"] + os.environ['LDAP_USER_LOGIN_ATTR'] = form["LDAP_USER_LOGIN_ATTR"] + os.environ['LDAP_USER_RDN_ATTR'] = form["LDAP_USER_RDN_ATTR"] + os.environ['PROD_DB_URI'] = form["PROD_DB_URI"] + os.environ['SMTP_ADMIN_EMAIL'] = form["SMTP_ADMIN_EMAIL"] + os.environ['SMTP_HOST'] = form["SMTP_HOST"] + os.environ['SMTP_PASSWORD'] = form["SMTP_PASSWORD"] + os.environ['SMTP_USER'] = form["SMTP_USER"] + os.environ['SNOW_ENABLED'] = form["SNOW_ENABLED"] + os.environ['SNOW_CLIENT_ID'] = form["SNOW_CLIENT_ID"] + os.environ['SNOW_CLIENT_SECRET'] = form["SNOW_CLIENT_SECRET"] + os.environ['SNOW_INSTANCE_NAME'] = form["SNOW_INSTANCE_NAME"] + os.environ['SNOW_PASSWORD'] = form["SNOW_PASSWORD"] + os.environ['SNOW_USERNAME'] = form["SNOW_USERNAME"] + os.environ['VERSION'] = form["VERSION"] + @admin.route('/dangerous/delete_all', methods=['POST']) def delete_all_data(): diff --git a/src/vr/db_models/setup.py b/src/vr/db_models/setup.py index 67adfc3b..b36fdc22 100644 --- a/src/vr/db_models/setup.py +++ b/src/vr/db_models/setup.py @@ -117,6 +117,43 @@ class AppConfig(db.Model): __table_args__ = {'extend_existing': True} id = db.Column(db.Integer, primary_key=True) first_access = db.Column(db.Boolean, nullable=False, default=True) + settings_initialized = db.Column(db.Boolean, nullable=False, default=False) + APP_EXT_URL = db.Column(db.String(200)) + AUTH_TYPE = db.Column(db.String(200)) + AZAD_AUTHORITY = db.Column(db.String(200)) + AZAD_CLIENT_ID = db.Column(db.String(200)) + AZAD_CLIENT_SECRET = db.Column(db.String(200)) + AZURE_KEYVAULT_NAME = db.Column(db.String(200)) + ENV = db.Column(db.String(200)) + INSECURE_OAUTH = db.Column(db.String(200)) + JENKINS_HOST = db.Column(db.String(200)) + JENKINS_KEY = db.Column(db.String(200)) + JENKINS_PROJECT = db.Column(db.String(200)) + JENKINS_STAGING_PROJECT = db.Column(db.String(200)) + JENKINS_TOKEN = db.Column(db.String(200)) + JENKINS_USER = db.Column(db.String(200)) + LDAP_BASE_DN = db.Column(db.String(200)) + LDAP_BIND_USER_DN = db.Column(db.String(200)) + LDAP_BIND_USER_PASSWORD = db.Column(db.String(200)) + LDAP_GROUP_DN = db.Column(db.String(200)) + LDAP_HOST = db.Column(db.String(200)) + LDAP_PORT = db.Column(db.String(200)) + LDAP_USER_DN = db.Column(db.String(200)) + LDAP_USER_LOGIN_ATTR = db.Column(db.String(200)) + LDAP_USER_RDN_ATTR = db.Column(db.String(200)) + PROD_DB_URI = db.Column(db.String(200)) + SMTP_ADMIN_EMAIL = db.Column(db.String(200)) + SMTP_HOST = db.Column(db.String(200)) + SMTP_PASSWORD = db.Column(db.String(200)) + SMTP_USER = db.Column(db.String(200)) + SNOW_CLIENT_ID = db.Column(db.String(200)) + SNOW_CLIENT_SECRET = db.Column(db.String(200)) + SNOW_INSTANCE_NAME = db.Column(db.String(200)) + SNOW_PASSWORD = db.Column(db.String(200)) + SNOW_USERNAME = db.Column(db.String(200)) + VERSION = db.Column(db.String(200)) + JENKINS_ENABLED = db.Column(db.String(200)) + SNOW_ENABLED = db.Column(db.String(200)) AppConfig() diff --git a/src/vr/templates/admin/settings.html b/src/vr/templates/admin/settings.html index 06a4bee5..a7564e1a 100644 --- a/src/vr/templates/admin/settings.html +++ b/src/vr/templates/admin/settings.html @@ -113,13 +113,135 @@

Application Settings

+ + +
+

General Settings

+ {% for key, value in settings.items() %} + {% if key in cat_general %} +
+ + {% if key == "AUTH_TYPE" %} + + {% elif key == "INSECURE_OAUTH" %} + + {% elif key == "PROD_DB_URI" %} +
+ {% elif key == "ENV" or key == "VERSION" %} + + {% else %} + + {% endif %} +
+ {% endif %} + {% endfor %} +
+ +
+

LDAP Settings

{% for key, value in settings.items() %} -
- - + {% if key in cat_ldap %} +
+ + +
+ {% endif %} + {% endfor %}
+ +
+

Azure Active Directory Settings

+ {% for key, value in settings.items() %} + {% if key in cat_azad %} +
+ + +
+ {% endif %} {% endfor %} +
+ +
+

SMTP Settings

+ {% for key, value in settings.items() %} + {% if key in smtp_settings %} +
+ + {% if key == 'SMTP_PASSWORD' %} +
+ {% else %} + + {% endif %} + +
+ {% endif %} + {% endfor %} +
+ +
+

Jenkins Settings

+ {% for key, value in settings.items() %} + {% if key in cat_jenkins %} +
+ {% if key == 'JENKINS_ENABLED' %} + + + {% elif key == 'JENKINS_KEY' %} + +
+ {% elif key == 'JENKINS_TOKEN' %} + +
+ {% else %} + + + {% endif %} +
+ {% endif %} + {% endfor %} +
+ + + + + +
+

ServiceNOW Settings

+ {% for key, value in settings.items() %} + {% if key in snow_settings %} +
+ {% if key == 'SNOW_ENABLED' %} + + + {% elif key == 'SNOW_CLIENT_SECRET' %} + +
+ {% elif key == 'SNOW_PASSWORD' %} + +
+ {% else %} + + + {% endif %} +
+ {% endif %} + {% endfor %} +
+
@@ -128,4 +250,157 @@

Application Settings

+ + {% endblock %} From 21ff0cd41580558c684fbfe7a5210fe55b87abfc Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sun, 17 Mar 2024 21:45:15 -0700 Subject: [PATCH 054/197] add function for table updates --- src/vr/__init__.py | 5 ++++ src/vr/db_models/updates.py | 56 +++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 src/vr/db_models/updates.py diff --git a/src/vr/__init__.py b/src/vr/__init__.py index e1bc03cf..a35d9183 100644 --- a/src/vr/__init__.py +++ b/src/vr/__init__.py @@ -29,6 +29,7 @@ from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_OAEP from requests.auth import HTTPBasicAuth +from vr.db_models.updates import createNewTables if AUTH_TYPE == 'azuread': from flask_session import Session @@ -180,6 +181,10 @@ def base64encode(value): return None +## Release-based updates ## +cwd = os.getcwd() +createNewTables(DB_URI) +print() ## Cronjob-like tasks section ## def train_model_every_six_hours(): scheduler = BackgroundScheduler() diff --git a/src/vr/db_models/updates.py b/src/vr/db_models/updates.py new file mode 100644 index 00000000..d6028a0f --- /dev/null +++ b/src/vr/db_models/updates.py @@ -0,0 +1,56 @@ +from flask_sqlalchemy import SQLAlchemy +from flask import Flask + + +def createNewTables(db_uri): + mock_app = Flask(__name__) + # Example database URI, replace it with your actual database URI + mock_app.config['SQLALCHEMY_DATABASE_URI'] = db_uri + mock_app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False + db = SQLAlchemy(mock_app) + + class AppConfig(db.Model): + __tablename__ = 'AppConfig' + __table_args__ = {'extend_existing': True} + id = db.Column(db.Integer, primary_key=True) + first_access = db.Column(db.Boolean, nullable=False, default=True) + settings_initialized = db.Column(db.Boolean, nullable=False, default=False) + APP_EXT_URL = db.Column(db.String(200)) + AUTH_TYPE = db.Column(db.String(200)) + AZAD_AUTHORITY = db.Column(db.String(200)) + AZAD_CLIENT_ID = db.Column(db.String(200)) + AZAD_CLIENT_SECRET = db.Column(db.String(200)) + AZURE_KEYVAULT_NAME = db.Column(db.String(200)) + ENV = db.Column(db.String(200)) + INSECURE_OAUTH = db.Column(db.String(200)) + JENKINS_HOST = db.Column(db.String(200)) + JENKINS_KEY = db.Column(db.String(200)) + JENKINS_PROJECT = db.Column(db.String(200)) + JENKINS_STAGING_PROJECT = db.Column(db.String(200)) + JENKINS_TOKEN = db.Column(db.String(200)) + JENKINS_USER = db.Column(db.String(200)) + LDAP_BASE_DN = db.Column(db.String(200)) + LDAP_BIND_USER_DN = db.Column(db.String(200)) + LDAP_BIND_USER_PASSWORD = db.Column(db.String(200)) + LDAP_GROUP_DN = db.Column(db.String(200)) + LDAP_HOST = db.Column(db.String(200)) + LDAP_PORT = db.Column(db.String(200)) + LDAP_USER_DN = db.Column(db.String(200)) + LDAP_USER_LOGIN_ATTR = db.Column(db.String(200)) + LDAP_USER_RDN_ATTR = db.Column(db.String(200)) + PROD_DB_URI = db.Column(db.String(200)) + SMTP_ADMIN_EMAIL = db.Column(db.String(200)) + SMTP_HOST = db.Column(db.String(200)) + SMTP_PASSWORD = db.Column(db.String(200)) + SMTP_USER = db.Column(db.String(200)) + SNOW_CLIENT_ID = db.Column(db.String(200)) + SNOW_CLIENT_SECRET = db.Column(db.String(200)) + SNOW_INSTANCE_NAME = db.Column(db.String(200)) + SNOW_PASSWORD = db.Column(db.String(200)) + SNOW_USERNAME = db.Column(db.String(200)) + VERSION = db.Column(db.String(200)) + JENKINS_ENABLED = db.Column(db.String(200)) + SNOW_ENABLED = db.Column(db.String(200)) + + with mock_app.app_context(): + db.create_all() From a59813684be8284c77d3121f0870c5e45dbe3ad0 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sun, 17 Mar 2024 21:51:13 -0700 Subject: [PATCH 055/197] Feature/update release based db settings (#503) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates --- src/vr/__init__.py | 5 ++++ src/vr/db_models/updates.py | 56 +++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 src/vr/db_models/updates.py diff --git a/src/vr/__init__.py b/src/vr/__init__.py index e1bc03cf..a35d9183 100644 --- a/src/vr/__init__.py +++ b/src/vr/__init__.py @@ -29,6 +29,7 @@ from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_OAEP from requests.auth import HTTPBasicAuth +from vr.db_models.updates import createNewTables if AUTH_TYPE == 'azuread': from flask_session import Session @@ -180,6 +181,10 @@ def base64encode(value): return None +## Release-based updates ## +cwd = os.getcwd() +createNewTables(DB_URI) +print() ## Cronjob-like tasks section ## def train_model_every_six_hours(): scheduler = BackgroundScheduler() diff --git a/src/vr/db_models/updates.py b/src/vr/db_models/updates.py new file mode 100644 index 00000000..d6028a0f --- /dev/null +++ b/src/vr/db_models/updates.py @@ -0,0 +1,56 @@ +from flask_sqlalchemy import SQLAlchemy +from flask import Flask + + +def createNewTables(db_uri): + mock_app = Flask(__name__) + # Example database URI, replace it with your actual database URI + mock_app.config['SQLALCHEMY_DATABASE_URI'] = db_uri + mock_app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False + db = SQLAlchemy(mock_app) + + class AppConfig(db.Model): + __tablename__ = 'AppConfig' + __table_args__ = {'extend_existing': True} + id = db.Column(db.Integer, primary_key=True) + first_access = db.Column(db.Boolean, nullable=False, default=True) + settings_initialized = db.Column(db.Boolean, nullable=False, default=False) + APP_EXT_URL = db.Column(db.String(200)) + AUTH_TYPE = db.Column(db.String(200)) + AZAD_AUTHORITY = db.Column(db.String(200)) + AZAD_CLIENT_ID = db.Column(db.String(200)) + AZAD_CLIENT_SECRET = db.Column(db.String(200)) + AZURE_KEYVAULT_NAME = db.Column(db.String(200)) + ENV = db.Column(db.String(200)) + INSECURE_OAUTH = db.Column(db.String(200)) + JENKINS_HOST = db.Column(db.String(200)) + JENKINS_KEY = db.Column(db.String(200)) + JENKINS_PROJECT = db.Column(db.String(200)) + JENKINS_STAGING_PROJECT = db.Column(db.String(200)) + JENKINS_TOKEN = db.Column(db.String(200)) + JENKINS_USER = db.Column(db.String(200)) + LDAP_BASE_DN = db.Column(db.String(200)) + LDAP_BIND_USER_DN = db.Column(db.String(200)) + LDAP_BIND_USER_PASSWORD = db.Column(db.String(200)) + LDAP_GROUP_DN = db.Column(db.String(200)) + LDAP_HOST = db.Column(db.String(200)) + LDAP_PORT = db.Column(db.String(200)) + LDAP_USER_DN = db.Column(db.String(200)) + LDAP_USER_LOGIN_ATTR = db.Column(db.String(200)) + LDAP_USER_RDN_ATTR = db.Column(db.String(200)) + PROD_DB_URI = db.Column(db.String(200)) + SMTP_ADMIN_EMAIL = db.Column(db.String(200)) + SMTP_HOST = db.Column(db.String(200)) + SMTP_PASSWORD = db.Column(db.String(200)) + SMTP_USER = db.Column(db.String(200)) + SNOW_CLIENT_ID = db.Column(db.String(200)) + SNOW_CLIENT_SECRET = db.Column(db.String(200)) + SNOW_INSTANCE_NAME = db.Column(db.String(200)) + SNOW_PASSWORD = db.Column(db.String(200)) + SNOW_USERNAME = db.Column(db.String(200)) + VERSION = db.Column(db.String(200)) + JENKINS_ENABLED = db.Column(db.String(200)) + SNOW_ENABLED = db.Column(db.String(200)) + + with mock_app.app_context(): + db.create_all() From 737d9e7df7c31df4a2a26dc7a0db5a5522728435 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sun, 17 Mar 2024 21:51:43 -0700 Subject: [PATCH 056/197] Release/0.1.0 beta/prod azure (#504) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile * Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * Feature/update settings function (#501) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * Feature/update release based db settings (#503) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates --- src/vr/__init__.py | 5 ++++ src/vr/db_models/updates.py | 56 +++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 src/vr/db_models/updates.py diff --git a/src/vr/__init__.py b/src/vr/__init__.py index e1bc03cf..a35d9183 100644 --- a/src/vr/__init__.py +++ b/src/vr/__init__.py @@ -29,6 +29,7 @@ from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_OAEP from requests.auth import HTTPBasicAuth +from vr.db_models.updates import createNewTables if AUTH_TYPE == 'azuread': from flask_session import Session @@ -180,6 +181,10 @@ def base64encode(value): return None +## Release-based updates ## +cwd = os.getcwd() +createNewTables(DB_URI) +print() ## Cronjob-like tasks section ## def train_model_every_six_hours(): scheduler = BackgroundScheduler() diff --git a/src/vr/db_models/updates.py b/src/vr/db_models/updates.py new file mode 100644 index 00000000..d6028a0f --- /dev/null +++ b/src/vr/db_models/updates.py @@ -0,0 +1,56 @@ +from flask_sqlalchemy import SQLAlchemy +from flask import Flask + + +def createNewTables(db_uri): + mock_app = Flask(__name__) + # Example database URI, replace it with your actual database URI + mock_app.config['SQLALCHEMY_DATABASE_URI'] = db_uri + mock_app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False + db = SQLAlchemy(mock_app) + + class AppConfig(db.Model): + __tablename__ = 'AppConfig' + __table_args__ = {'extend_existing': True} + id = db.Column(db.Integer, primary_key=True) + first_access = db.Column(db.Boolean, nullable=False, default=True) + settings_initialized = db.Column(db.Boolean, nullable=False, default=False) + APP_EXT_URL = db.Column(db.String(200)) + AUTH_TYPE = db.Column(db.String(200)) + AZAD_AUTHORITY = db.Column(db.String(200)) + AZAD_CLIENT_ID = db.Column(db.String(200)) + AZAD_CLIENT_SECRET = db.Column(db.String(200)) + AZURE_KEYVAULT_NAME = db.Column(db.String(200)) + ENV = db.Column(db.String(200)) + INSECURE_OAUTH = db.Column(db.String(200)) + JENKINS_HOST = db.Column(db.String(200)) + JENKINS_KEY = db.Column(db.String(200)) + JENKINS_PROJECT = db.Column(db.String(200)) + JENKINS_STAGING_PROJECT = db.Column(db.String(200)) + JENKINS_TOKEN = db.Column(db.String(200)) + JENKINS_USER = db.Column(db.String(200)) + LDAP_BASE_DN = db.Column(db.String(200)) + LDAP_BIND_USER_DN = db.Column(db.String(200)) + LDAP_BIND_USER_PASSWORD = db.Column(db.String(200)) + LDAP_GROUP_DN = db.Column(db.String(200)) + LDAP_HOST = db.Column(db.String(200)) + LDAP_PORT = db.Column(db.String(200)) + LDAP_USER_DN = db.Column(db.String(200)) + LDAP_USER_LOGIN_ATTR = db.Column(db.String(200)) + LDAP_USER_RDN_ATTR = db.Column(db.String(200)) + PROD_DB_URI = db.Column(db.String(200)) + SMTP_ADMIN_EMAIL = db.Column(db.String(200)) + SMTP_HOST = db.Column(db.String(200)) + SMTP_PASSWORD = db.Column(db.String(200)) + SMTP_USER = db.Column(db.String(200)) + SNOW_CLIENT_ID = db.Column(db.String(200)) + SNOW_CLIENT_SECRET = db.Column(db.String(200)) + SNOW_INSTANCE_NAME = db.Column(db.String(200)) + SNOW_PASSWORD = db.Column(db.String(200)) + SNOW_USERNAME = db.Column(db.String(200)) + VERSION = db.Column(db.String(200)) + JENKINS_ENABLED = db.Column(db.String(200)) + SNOW_ENABLED = db.Column(db.String(200)) + + with mock_app.app_context(): + db.create_all() From cfcaab32d347f5e31733fd0067d968ad987be7c4 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:00:43 -0700 Subject: [PATCH 057/197] updated function for db updates --- src/vr/__init__.py | 5 +- src/vr/db_models/updates.py | 140 ++++++++++++++++++++++-------------- 2 files changed, 90 insertions(+), 55 deletions(-) diff --git a/src/vr/__init__.py b/src/vr/__init__.py index a35d9183..42a86ea1 100644 --- a/src/vr/__init__.py +++ b/src/vr/__init__.py @@ -182,9 +182,8 @@ def base64encode(value): ## Release-based updates ## -cwd = os.getcwd() -createNewTables(DB_URI) -print() +createNewTables(app) + ## Cronjob-like tasks section ## def train_model_every_six_hours(): scheduler = BackgroundScheduler() diff --git a/src/vr/db_models/updates.py b/src/vr/db_models/updates.py index d6028a0f..93106286 100644 --- a/src/vr/db_models/updates.py +++ b/src/vr/db_models/updates.py @@ -1,56 +1,92 @@ -from flask_sqlalchemy import SQLAlchemy -from flask import Flask +import mysql.connector +import sqlite3 +import os -def createNewTables(db_uri): - mock_app = Flask(__name__) - # Example database URI, replace it with your actual database URI - mock_app.config['SQLALCHEMY_DATABASE_URI'] = db_uri - mock_app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False - db = SQLAlchemy(mock_app) +def get_client(app): + if app.config['RUNTIME_ENV'] == 'test': + cur_path = os.getcwd() + if 'www' in cur_path and 'html' in cur_path: + db_uri = '/var/www/html/src/instance/database.db' + else: + db_uri = 'instance/database.db' + db = sqlite3.connect(db_uri) + cur = db.cursor() + return cur, db + else: + db_uri = app.config['SQLALCHEMY_DATABASE_URI'] + main_part = db_uri.split('://')[1] + un = main_part.split(':', 1)[0] + db_name = main_part.rsplit('/', 1)[1] + host_and_port = main_part.rsplit('@', 1)[1].replace(f"/{db_name}", '') + host = host_and_port.split(':')[0] + port = int(host_and_port.split(':')[1]) + pw = main_part.split(':', 1)[1].replace(f"@{host}", '').replace(f"/{db_name}", '').replace(f":{port}", "") + db = mysql.connector.connect(host=host, database=db_name, user=un, password=pw, port=port) + cur = db.cursor() + return cur, db - class AppConfig(db.Model): - __tablename__ = 'AppConfig' - __table_args__ = {'extend_existing': True} - id = db.Column(db.Integer, primary_key=True) - first_access = db.Column(db.Boolean, nullable=False, default=True) - settings_initialized = db.Column(db.Boolean, nullable=False, default=False) - APP_EXT_URL = db.Column(db.String(200)) - AUTH_TYPE = db.Column(db.String(200)) - AZAD_AUTHORITY = db.Column(db.String(200)) - AZAD_CLIENT_ID = db.Column(db.String(200)) - AZAD_CLIENT_SECRET = db.Column(db.String(200)) - AZURE_KEYVAULT_NAME = db.Column(db.String(200)) - ENV = db.Column(db.String(200)) - INSECURE_OAUTH = db.Column(db.String(200)) - JENKINS_HOST = db.Column(db.String(200)) - JENKINS_KEY = db.Column(db.String(200)) - JENKINS_PROJECT = db.Column(db.String(200)) - JENKINS_STAGING_PROJECT = db.Column(db.String(200)) - JENKINS_TOKEN = db.Column(db.String(200)) - JENKINS_USER = db.Column(db.String(200)) - LDAP_BASE_DN = db.Column(db.String(200)) - LDAP_BIND_USER_DN = db.Column(db.String(200)) - LDAP_BIND_USER_PASSWORD = db.Column(db.String(200)) - LDAP_GROUP_DN = db.Column(db.String(200)) - LDAP_HOST = db.Column(db.String(200)) - LDAP_PORT = db.Column(db.String(200)) - LDAP_USER_DN = db.Column(db.String(200)) - LDAP_USER_LOGIN_ATTR = db.Column(db.String(200)) - LDAP_USER_RDN_ATTR = db.Column(db.String(200)) - PROD_DB_URI = db.Column(db.String(200)) - SMTP_ADMIN_EMAIL = db.Column(db.String(200)) - SMTP_HOST = db.Column(db.String(200)) - SMTP_PASSWORD = db.Column(db.String(200)) - SMTP_USER = db.Column(db.String(200)) - SNOW_CLIENT_ID = db.Column(db.String(200)) - SNOW_CLIENT_SECRET = db.Column(db.String(200)) - SNOW_INSTANCE_NAME = db.Column(db.String(200)) - SNOW_PASSWORD = db.Column(db.String(200)) - SNOW_USERNAME = db.Column(db.String(200)) - VERSION = db.Column(db.String(200)) - JENKINS_ENABLED = db.Column(db.String(200)) - SNOW_ENABLED = db.Column(db.String(200)) - with mock_app.app_context(): - db.create_all() +def createNewTables(app): + cur, db = get_client(app) + if app.config['RUNTIME_ENV'] == 'test': + sql = "PRAGMA table_info('AppConfig')" + else: + sql = "SELECT column_name FROM information_schema.columns WHERE table_schema = 'vulnremediator' AND table_name = 'AppConfig'" + cur.execute(sql) + rows = cur.fetchall() + fields = [] + for i in rows: + fields.append(i[1]) + new_fields = [ + {"name": "APP_EXT_URL", "type": "VARCHAR", "char_num": 200}, + {"name": "AUTH_TYPE", "type": "VARCHAR", "char_num": 200}, + {"name": "AZAD_AUTHORITY", "type": "VARCHAR", "char_num": 200}, + {"name": "AZAD_CLIENT_ID", "type": "VARCHAR", "char_num": 200}, + {"name": "AZAD_CLIENT_SECRET", "type": "VARCHAR", "char_num": 200}, + {"name": "AZURE_KEYVAULT_NAME", "type": "VARCHAR", "char_num": 200}, + {"name": "ENV", "type": "VARCHAR", "char_num": 200}, + {"name": "INSECURE_OAUTH", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_HOST", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_KEY", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_PROJECT", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_STAGING_PROJECT", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_TOKEN", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_USER", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_BASE_DN", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_BIND_USER_DN", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_BIND_USER_PASSWORD", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_GROUP_DN", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_HOST", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_PORT", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_USER_DN", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_USER_LOGIN_ATTR", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_USER_RDN_ATTR", "type": "VARCHAR", "char_num": 200}, + {"name": "PROD_DB_URI", "type": "VARCHAR", "char_num": 200}, + {"name": "SMTP_ADMIN_EMAIL", "type": "VARCHAR", "char_num": 200}, + {"name": "SMTP_HOST", "type": "VARCHAR", "char_num": 200}, + {"name": "SMTP_PASSWORD", "type": "VARCHAR", "char_num": 200}, + {"name": "SMTP_USER", "type": "VARCHAR", "char_num": 200}, + {"name": "SNOW_CLIENT_ID", "type": "VARCHAR", "char_num": 200}, + {"name": "SNOW_CLIENT_SECRET", "type": "VARCHAR", "char_num": 200}, + {"name": "SNOW_INSTANCE_NAME", "type": "VARCHAR", "char_num": 200}, + {"name": "SNOW_PASSWORD", "type": "VARCHAR", "char_num": 200}, + {"name": "SNOW_USERNAME", "type": "VARCHAR", "char_num": 200}, + {"name": "VERSION", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_ENABLED", "type": "VARCHAR", "char_num": 200}, + {"name": "SNOW_ENABLED", "type": "VARCHAR", "char_num": 200} + ] + + for i in new_fields: + if i['name'] not in fields: + if app.config['RUNTIME_ENV'] == 'test': + if i['type'] == 'VARCHAR': + var_stmt = f"VARCHAR({i['char_num']})" + sql = "ALTER TABLE AppConfig ADD COLUMN" + i['name'] + var_stmt + else: + if i['type'] == 'VARCHAR': + var_stmt = "TEXT" + sql = "ALTER TABLE AppConfig ADD COLUMN" + i['name'] + var_stmt + cur.execute(sql) + db.commit() + From bc17dcc362fff6a672633332c6c0e28fbaf8f2fa Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:08:12 -0700 Subject: [PATCH 058/197] Feature/update release based db settings (#505) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates --- src/vr/__init__.py | 5 +- src/vr/db_models/updates.py | 140 ++++++++++++++++++++++-------------- 2 files changed, 90 insertions(+), 55 deletions(-) diff --git a/src/vr/__init__.py b/src/vr/__init__.py index a35d9183..42a86ea1 100644 --- a/src/vr/__init__.py +++ b/src/vr/__init__.py @@ -182,9 +182,8 @@ def base64encode(value): ## Release-based updates ## -cwd = os.getcwd() -createNewTables(DB_URI) -print() +createNewTables(app) + ## Cronjob-like tasks section ## def train_model_every_six_hours(): scheduler = BackgroundScheduler() diff --git a/src/vr/db_models/updates.py b/src/vr/db_models/updates.py index d6028a0f..93106286 100644 --- a/src/vr/db_models/updates.py +++ b/src/vr/db_models/updates.py @@ -1,56 +1,92 @@ -from flask_sqlalchemy import SQLAlchemy -from flask import Flask +import mysql.connector +import sqlite3 +import os -def createNewTables(db_uri): - mock_app = Flask(__name__) - # Example database URI, replace it with your actual database URI - mock_app.config['SQLALCHEMY_DATABASE_URI'] = db_uri - mock_app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False - db = SQLAlchemy(mock_app) +def get_client(app): + if app.config['RUNTIME_ENV'] == 'test': + cur_path = os.getcwd() + if 'www' in cur_path and 'html' in cur_path: + db_uri = '/var/www/html/src/instance/database.db' + else: + db_uri = 'instance/database.db' + db = sqlite3.connect(db_uri) + cur = db.cursor() + return cur, db + else: + db_uri = app.config['SQLALCHEMY_DATABASE_URI'] + main_part = db_uri.split('://')[1] + un = main_part.split(':', 1)[0] + db_name = main_part.rsplit('/', 1)[1] + host_and_port = main_part.rsplit('@', 1)[1].replace(f"/{db_name}", '') + host = host_and_port.split(':')[0] + port = int(host_and_port.split(':')[1]) + pw = main_part.split(':', 1)[1].replace(f"@{host}", '').replace(f"/{db_name}", '').replace(f":{port}", "") + db = mysql.connector.connect(host=host, database=db_name, user=un, password=pw, port=port) + cur = db.cursor() + return cur, db - class AppConfig(db.Model): - __tablename__ = 'AppConfig' - __table_args__ = {'extend_existing': True} - id = db.Column(db.Integer, primary_key=True) - first_access = db.Column(db.Boolean, nullable=False, default=True) - settings_initialized = db.Column(db.Boolean, nullable=False, default=False) - APP_EXT_URL = db.Column(db.String(200)) - AUTH_TYPE = db.Column(db.String(200)) - AZAD_AUTHORITY = db.Column(db.String(200)) - AZAD_CLIENT_ID = db.Column(db.String(200)) - AZAD_CLIENT_SECRET = db.Column(db.String(200)) - AZURE_KEYVAULT_NAME = db.Column(db.String(200)) - ENV = db.Column(db.String(200)) - INSECURE_OAUTH = db.Column(db.String(200)) - JENKINS_HOST = db.Column(db.String(200)) - JENKINS_KEY = db.Column(db.String(200)) - JENKINS_PROJECT = db.Column(db.String(200)) - JENKINS_STAGING_PROJECT = db.Column(db.String(200)) - JENKINS_TOKEN = db.Column(db.String(200)) - JENKINS_USER = db.Column(db.String(200)) - LDAP_BASE_DN = db.Column(db.String(200)) - LDAP_BIND_USER_DN = db.Column(db.String(200)) - LDAP_BIND_USER_PASSWORD = db.Column(db.String(200)) - LDAP_GROUP_DN = db.Column(db.String(200)) - LDAP_HOST = db.Column(db.String(200)) - LDAP_PORT = db.Column(db.String(200)) - LDAP_USER_DN = db.Column(db.String(200)) - LDAP_USER_LOGIN_ATTR = db.Column(db.String(200)) - LDAP_USER_RDN_ATTR = db.Column(db.String(200)) - PROD_DB_URI = db.Column(db.String(200)) - SMTP_ADMIN_EMAIL = db.Column(db.String(200)) - SMTP_HOST = db.Column(db.String(200)) - SMTP_PASSWORD = db.Column(db.String(200)) - SMTP_USER = db.Column(db.String(200)) - SNOW_CLIENT_ID = db.Column(db.String(200)) - SNOW_CLIENT_SECRET = db.Column(db.String(200)) - SNOW_INSTANCE_NAME = db.Column(db.String(200)) - SNOW_PASSWORD = db.Column(db.String(200)) - SNOW_USERNAME = db.Column(db.String(200)) - VERSION = db.Column(db.String(200)) - JENKINS_ENABLED = db.Column(db.String(200)) - SNOW_ENABLED = db.Column(db.String(200)) - with mock_app.app_context(): - db.create_all() +def createNewTables(app): + cur, db = get_client(app) + if app.config['RUNTIME_ENV'] == 'test': + sql = "PRAGMA table_info('AppConfig')" + else: + sql = "SELECT column_name FROM information_schema.columns WHERE table_schema = 'vulnremediator' AND table_name = 'AppConfig'" + cur.execute(sql) + rows = cur.fetchall() + fields = [] + for i in rows: + fields.append(i[1]) + new_fields = [ + {"name": "APP_EXT_URL", "type": "VARCHAR", "char_num": 200}, + {"name": "AUTH_TYPE", "type": "VARCHAR", "char_num": 200}, + {"name": "AZAD_AUTHORITY", "type": "VARCHAR", "char_num": 200}, + {"name": "AZAD_CLIENT_ID", "type": "VARCHAR", "char_num": 200}, + {"name": "AZAD_CLIENT_SECRET", "type": "VARCHAR", "char_num": 200}, + {"name": "AZURE_KEYVAULT_NAME", "type": "VARCHAR", "char_num": 200}, + {"name": "ENV", "type": "VARCHAR", "char_num": 200}, + {"name": "INSECURE_OAUTH", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_HOST", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_KEY", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_PROJECT", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_STAGING_PROJECT", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_TOKEN", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_USER", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_BASE_DN", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_BIND_USER_DN", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_BIND_USER_PASSWORD", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_GROUP_DN", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_HOST", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_PORT", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_USER_DN", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_USER_LOGIN_ATTR", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_USER_RDN_ATTR", "type": "VARCHAR", "char_num": 200}, + {"name": "PROD_DB_URI", "type": "VARCHAR", "char_num": 200}, + {"name": "SMTP_ADMIN_EMAIL", "type": "VARCHAR", "char_num": 200}, + {"name": "SMTP_HOST", "type": "VARCHAR", "char_num": 200}, + {"name": "SMTP_PASSWORD", "type": "VARCHAR", "char_num": 200}, + {"name": "SMTP_USER", "type": "VARCHAR", "char_num": 200}, + {"name": "SNOW_CLIENT_ID", "type": "VARCHAR", "char_num": 200}, + {"name": "SNOW_CLIENT_SECRET", "type": "VARCHAR", "char_num": 200}, + {"name": "SNOW_INSTANCE_NAME", "type": "VARCHAR", "char_num": 200}, + {"name": "SNOW_PASSWORD", "type": "VARCHAR", "char_num": 200}, + {"name": "SNOW_USERNAME", "type": "VARCHAR", "char_num": 200}, + {"name": "VERSION", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_ENABLED", "type": "VARCHAR", "char_num": 200}, + {"name": "SNOW_ENABLED", "type": "VARCHAR", "char_num": 200} + ] + + for i in new_fields: + if i['name'] not in fields: + if app.config['RUNTIME_ENV'] == 'test': + if i['type'] == 'VARCHAR': + var_stmt = f"VARCHAR({i['char_num']})" + sql = "ALTER TABLE AppConfig ADD COLUMN" + i['name'] + var_stmt + else: + if i['type'] == 'VARCHAR': + var_stmt = "TEXT" + sql = "ALTER TABLE AppConfig ADD COLUMN" + i['name'] + var_stmt + cur.execute(sql) + db.commit() + From 5c1694963063b1bd00c1bd628bfe2800d0529977 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:09:38 -0700 Subject: [PATCH 059/197] Release/0.1.0 beta/prod azure (#506) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile * Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * Feature/update settings function (#501) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * Feature/update release based db settings (#503) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * Feature/update release based db settings (#505) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates --- src/vr/__init__.py | 5 +- src/vr/db_models/updates.py | 140 ++++++++++++++++++++++-------------- 2 files changed, 90 insertions(+), 55 deletions(-) diff --git a/src/vr/__init__.py b/src/vr/__init__.py index a35d9183..42a86ea1 100644 --- a/src/vr/__init__.py +++ b/src/vr/__init__.py @@ -182,9 +182,8 @@ def base64encode(value): ## Release-based updates ## -cwd = os.getcwd() -createNewTables(DB_URI) -print() +createNewTables(app) + ## Cronjob-like tasks section ## def train_model_every_six_hours(): scheduler = BackgroundScheduler() diff --git a/src/vr/db_models/updates.py b/src/vr/db_models/updates.py index d6028a0f..93106286 100644 --- a/src/vr/db_models/updates.py +++ b/src/vr/db_models/updates.py @@ -1,56 +1,92 @@ -from flask_sqlalchemy import SQLAlchemy -from flask import Flask +import mysql.connector +import sqlite3 +import os -def createNewTables(db_uri): - mock_app = Flask(__name__) - # Example database URI, replace it with your actual database URI - mock_app.config['SQLALCHEMY_DATABASE_URI'] = db_uri - mock_app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False - db = SQLAlchemy(mock_app) +def get_client(app): + if app.config['RUNTIME_ENV'] == 'test': + cur_path = os.getcwd() + if 'www' in cur_path and 'html' in cur_path: + db_uri = '/var/www/html/src/instance/database.db' + else: + db_uri = 'instance/database.db' + db = sqlite3.connect(db_uri) + cur = db.cursor() + return cur, db + else: + db_uri = app.config['SQLALCHEMY_DATABASE_URI'] + main_part = db_uri.split('://')[1] + un = main_part.split(':', 1)[0] + db_name = main_part.rsplit('/', 1)[1] + host_and_port = main_part.rsplit('@', 1)[1].replace(f"/{db_name}", '') + host = host_and_port.split(':')[0] + port = int(host_and_port.split(':')[1]) + pw = main_part.split(':', 1)[1].replace(f"@{host}", '').replace(f"/{db_name}", '').replace(f":{port}", "") + db = mysql.connector.connect(host=host, database=db_name, user=un, password=pw, port=port) + cur = db.cursor() + return cur, db - class AppConfig(db.Model): - __tablename__ = 'AppConfig' - __table_args__ = {'extend_existing': True} - id = db.Column(db.Integer, primary_key=True) - first_access = db.Column(db.Boolean, nullable=False, default=True) - settings_initialized = db.Column(db.Boolean, nullable=False, default=False) - APP_EXT_URL = db.Column(db.String(200)) - AUTH_TYPE = db.Column(db.String(200)) - AZAD_AUTHORITY = db.Column(db.String(200)) - AZAD_CLIENT_ID = db.Column(db.String(200)) - AZAD_CLIENT_SECRET = db.Column(db.String(200)) - AZURE_KEYVAULT_NAME = db.Column(db.String(200)) - ENV = db.Column(db.String(200)) - INSECURE_OAUTH = db.Column(db.String(200)) - JENKINS_HOST = db.Column(db.String(200)) - JENKINS_KEY = db.Column(db.String(200)) - JENKINS_PROJECT = db.Column(db.String(200)) - JENKINS_STAGING_PROJECT = db.Column(db.String(200)) - JENKINS_TOKEN = db.Column(db.String(200)) - JENKINS_USER = db.Column(db.String(200)) - LDAP_BASE_DN = db.Column(db.String(200)) - LDAP_BIND_USER_DN = db.Column(db.String(200)) - LDAP_BIND_USER_PASSWORD = db.Column(db.String(200)) - LDAP_GROUP_DN = db.Column(db.String(200)) - LDAP_HOST = db.Column(db.String(200)) - LDAP_PORT = db.Column(db.String(200)) - LDAP_USER_DN = db.Column(db.String(200)) - LDAP_USER_LOGIN_ATTR = db.Column(db.String(200)) - LDAP_USER_RDN_ATTR = db.Column(db.String(200)) - PROD_DB_URI = db.Column(db.String(200)) - SMTP_ADMIN_EMAIL = db.Column(db.String(200)) - SMTP_HOST = db.Column(db.String(200)) - SMTP_PASSWORD = db.Column(db.String(200)) - SMTP_USER = db.Column(db.String(200)) - SNOW_CLIENT_ID = db.Column(db.String(200)) - SNOW_CLIENT_SECRET = db.Column(db.String(200)) - SNOW_INSTANCE_NAME = db.Column(db.String(200)) - SNOW_PASSWORD = db.Column(db.String(200)) - SNOW_USERNAME = db.Column(db.String(200)) - VERSION = db.Column(db.String(200)) - JENKINS_ENABLED = db.Column(db.String(200)) - SNOW_ENABLED = db.Column(db.String(200)) - with mock_app.app_context(): - db.create_all() +def createNewTables(app): + cur, db = get_client(app) + if app.config['RUNTIME_ENV'] == 'test': + sql = "PRAGMA table_info('AppConfig')" + else: + sql = "SELECT column_name FROM information_schema.columns WHERE table_schema = 'vulnremediator' AND table_name = 'AppConfig'" + cur.execute(sql) + rows = cur.fetchall() + fields = [] + for i in rows: + fields.append(i[1]) + new_fields = [ + {"name": "APP_EXT_URL", "type": "VARCHAR", "char_num": 200}, + {"name": "AUTH_TYPE", "type": "VARCHAR", "char_num": 200}, + {"name": "AZAD_AUTHORITY", "type": "VARCHAR", "char_num": 200}, + {"name": "AZAD_CLIENT_ID", "type": "VARCHAR", "char_num": 200}, + {"name": "AZAD_CLIENT_SECRET", "type": "VARCHAR", "char_num": 200}, + {"name": "AZURE_KEYVAULT_NAME", "type": "VARCHAR", "char_num": 200}, + {"name": "ENV", "type": "VARCHAR", "char_num": 200}, + {"name": "INSECURE_OAUTH", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_HOST", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_KEY", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_PROJECT", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_STAGING_PROJECT", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_TOKEN", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_USER", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_BASE_DN", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_BIND_USER_DN", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_BIND_USER_PASSWORD", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_GROUP_DN", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_HOST", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_PORT", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_USER_DN", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_USER_LOGIN_ATTR", "type": "VARCHAR", "char_num": 200}, + {"name": "LDAP_USER_RDN_ATTR", "type": "VARCHAR", "char_num": 200}, + {"name": "PROD_DB_URI", "type": "VARCHAR", "char_num": 200}, + {"name": "SMTP_ADMIN_EMAIL", "type": "VARCHAR", "char_num": 200}, + {"name": "SMTP_HOST", "type": "VARCHAR", "char_num": 200}, + {"name": "SMTP_PASSWORD", "type": "VARCHAR", "char_num": 200}, + {"name": "SMTP_USER", "type": "VARCHAR", "char_num": 200}, + {"name": "SNOW_CLIENT_ID", "type": "VARCHAR", "char_num": 200}, + {"name": "SNOW_CLIENT_SECRET", "type": "VARCHAR", "char_num": 200}, + {"name": "SNOW_INSTANCE_NAME", "type": "VARCHAR", "char_num": 200}, + {"name": "SNOW_PASSWORD", "type": "VARCHAR", "char_num": 200}, + {"name": "SNOW_USERNAME", "type": "VARCHAR", "char_num": 200}, + {"name": "VERSION", "type": "VARCHAR", "char_num": 200}, + {"name": "JENKINS_ENABLED", "type": "VARCHAR", "char_num": 200}, + {"name": "SNOW_ENABLED", "type": "VARCHAR", "char_num": 200} + ] + + for i in new_fields: + if i['name'] not in fields: + if app.config['RUNTIME_ENV'] == 'test': + if i['type'] == 'VARCHAR': + var_stmt = f"VARCHAR({i['char_num']})" + sql = "ALTER TABLE AppConfig ADD COLUMN" + i['name'] + var_stmt + else: + if i['type'] == 'VARCHAR': + var_stmt = "TEXT" + sql = "ALTER TABLE AppConfig ADD COLUMN" + i['name'] + var_stmt + cur.execute(sql) + db.commit() + From 334bc6884965d92083006cf45eb5d35511681405 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:20:31 -0700 Subject: [PATCH 060/197] Feature/fix db syntax (#507) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates From 881a26f04a4e740526d108c666644a75e752fe74 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:20:58 -0700 Subject: [PATCH 061/197] Release/0.1.0 beta/prod azure (#508) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile * Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * Feature/update settings function (#501) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * Feature/update release based db settings (#503) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * Feature/update release based db settings (#505) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#507) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates From fe6982798edee75a849db61adb9cbafac4141dee Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 18 Mar 2024 06:50:36 -0700 Subject: [PATCH 062/197] Update updates.py --- src/vr/db_models/updates.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/vr/db_models/updates.py b/src/vr/db_models/updates.py index 93106286..d9a2c8c8 100644 --- a/src/vr/db_models/updates.py +++ b/src/vr/db_models/updates.py @@ -37,7 +37,10 @@ def createNewTables(app): rows = cur.fetchall() fields = [] for i in rows: - fields.append(i[1]) + if app.config['RUNTIME_ENV'] == 'test': + fields.append(i[1]) + else: + fields.append(i[0]) new_fields = [ {"name": "APP_EXT_URL", "type": "VARCHAR", "char_num": 200}, {"name": "AUTH_TYPE", "type": "VARCHAR", "char_num": 200}, From 24a95b38915db0fa3fac8ae8e91d878e2a1c0234 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 18 Mar 2024 06:56:45 -0700 Subject: [PATCH 063/197] Feature/fix db syntax (#509) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py --- src/vr/db_models/updates.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/vr/db_models/updates.py b/src/vr/db_models/updates.py index 93106286..d9a2c8c8 100644 --- a/src/vr/db_models/updates.py +++ b/src/vr/db_models/updates.py @@ -37,7 +37,10 @@ def createNewTables(app): rows = cur.fetchall() fields = [] for i in rows: - fields.append(i[1]) + if app.config['RUNTIME_ENV'] == 'test': + fields.append(i[1]) + else: + fields.append(i[0]) new_fields = [ {"name": "APP_EXT_URL", "type": "VARCHAR", "char_num": 200}, {"name": "AUTH_TYPE", "type": "VARCHAR", "char_num": 200}, From 2514b5aa94c27a6871a3ec739fdcd8fed738c50b Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 18 Mar 2024 06:57:50 -0700 Subject: [PATCH 064/197] Release/0.1.0 beta/prod azure (#510) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile * Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * Feature/update settings function (#501) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * Feature/update release based db settings (#503) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * Feature/update release based db settings (#505) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#507) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#509) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py --- src/vr/db_models/updates.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/vr/db_models/updates.py b/src/vr/db_models/updates.py index 93106286..d9a2c8c8 100644 --- a/src/vr/db_models/updates.py +++ b/src/vr/db_models/updates.py @@ -37,7 +37,10 @@ def createNewTables(app): rows = cur.fetchall() fields = [] for i in rows: - fields.append(i[1]) + if app.config['RUNTIME_ENV'] == 'test': + fields.append(i[1]) + else: + fields.append(i[0]) new_fields = [ {"name": "APP_EXT_URL", "type": "VARCHAR", "char_num": 200}, {"name": "AUTH_TYPE", "type": "VARCHAR", "char_num": 200}, From b84553ccf452ae2eb6e077a36c801a7600064d54 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 18 Mar 2024 07:07:43 -0700 Subject: [PATCH 065/197] Update updates.py --- src/vr/db_models/updates.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vr/db_models/updates.py b/src/vr/db_models/updates.py index d9a2c8c8..a3105305 100644 --- a/src/vr/db_models/updates.py +++ b/src/vr/db_models/updates.py @@ -85,11 +85,11 @@ def createNewTables(app): if app.config['RUNTIME_ENV'] == 'test': if i['type'] == 'VARCHAR': var_stmt = f"VARCHAR({i['char_num']})" - sql = "ALTER TABLE AppConfig ADD COLUMN" + i['name'] + var_stmt + sql = "ALTER TABLE AppConfig ADD COLUMN " + i['name'] + " " + var_stmt else: if i['type'] == 'VARCHAR': var_stmt = "TEXT" - sql = "ALTER TABLE AppConfig ADD COLUMN" + i['name'] + var_stmt + sql = "ALTER TABLE AppConfig ADD COLUMN " + i['name'] + " " + var_stmt cur.execute(sql) db.commit() From 0b07ab020b78d5c769e4b0b067db886e8b126382 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 18 Mar 2024 07:13:57 -0700 Subject: [PATCH 066/197] Feature/fix syntax error (#511) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py --- src/vr/db_models/updates.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vr/db_models/updates.py b/src/vr/db_models/updates.py index d9a2c8c8..a3105305 100644 --- a/src/vr/db_models/updates.py +++ b/src/vr/db_models/updates.py @@ -85,11 +85,11 @@ def createNewTables(app): if app.config['RUNTIME_ENV'] == 'test': if i['type'] == 'VARCHAR': var_stmt = f"VARCHAR({i['char_num']})" - sql = "ALTER TABLE AppConfig ADD COLUMN" + i['name'] + var_stmt + sql = "ALTER TABLE AppConfig ADD COLUMN " + i['name'] + " " + var_stmt else: if i['type'] == 'VARCHAR': var_stmt = "TEXT" - sql = "ALTER TABLE AppConfig ADD COLUMN" + i['name'] + var_stmt + sql = "ALTER TABLE AppConfig ADD COLUMN " + i['name'] + " " + var_stmt cur.execute(sql) db.commit() From 22d4989ac329ba34b9371a430cb22b8d3e8efdfb Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 18 Mar 2024 07:17:33 -0700 Subject: [PATCH 067/197] Release/0.1.0 beta/prod azure (#512) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile * Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * Feature/update settings function (#501) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * Feature/update release based db settings (#503) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * Feature/update release based db settings (#505) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#507) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#509) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Feature/fix syntax error (#511) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py --- src/vr/db_models/updates.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vr/db_models/updates.py b/src/vr/db_models/updates.py index d9a2c8c8..a3105305 100644 --- a/src/vr/db_models/updates.py +++ b/src/vr/db_models/updates.py @@ -85,11 +85,11 @@ def createNewTables(app): if app.config['RUNTIME_ENV'] == 'test': if i['type'] == 'VARCHAR': var_stmt = f"VARCHAR({i['char_num']})" - sql = "ALTER TABLE AppConfig ADD COLUMN" + i['name'] + var_stmt + sql = "ALTER TABLE AppConfig ADD COLUMN " + i['name'] + " " + var_stmt else: if i['type'] == 'VARCHAR': var_stmt = "TEXT" - sql = "ALTER TABLE AppConfig ADD COLUMN" + i['name'] + var_stmt + sql = "ALTER TABLE AppConfig ADD COLUMN " + i['name'] + " " + var_stmt cur.execute(sql) db.commit() From fa8075437fd0be26df3f1d8469966281b32cef32 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 18 Mar 2024 07:36:08 -0700 Subject: [PATCH 068/197] Update updates.py --- src/vr/db_models/updates.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vr/db_models/updates.py b/src/vr/db_models/updates.py index a3105305..f1e28b1b 100644 --- a/src/vr/db_models/updates.py +++ b/src/vr/db_models/updates.py @@ -42,6 +42,7 @@ def createNewTables(app): else: fields.append(i[0]) new_fields = [ + {"name": "settings_initialized", "type": "BOOLEAN", "default": 0}, {"name": "APP_EXT_URL", "type": "VARCHAR", "char_num": 200}, {"name": "AUTH_TYPE", "type": "VARCHAR", "char_num": 200}, {"name": "AZAD_AUTHORITY", "type": "VARCHAR", "char_num": 200}, @@ -85,10 +86,14 @@ def createNewTables(app): if app.config['RUNTIME_ENV'] == 'test': if i['type'] == 'VARCHAR': var_stmt = f"VARCHAR({i['char_num']})" + elif i['type'] == 'BOOLEAN': + var_stmt = f"BOOLEAN DEFAULT {i['default']}" sql = "ALTER TABLE AppConfig ADD COLUMN " + i['name'] + " " + var_stmt else: if i['type'] == 'VARCHAR': var_stmt = "TEXT" + elif i['type'] == 'BOOLEAN': + var_stmt = f"BOOLEAN DEFAULT {i['default']}" sql = "ALTER TABLE AppConfig ADD COLUMN " + i['name'] + " " + var_stmt cur.execute(sql) db.commit() From e246ba0561c49be9036c909ec6c79e39212aaf6c Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 18 Mar 2024 07:42:49 -0700 Subject: [PATCH 069/197] Feature/fix syntax error (#513) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py --- src/vr/db_models/updates.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vr/db_models/updates.py b/src/vr/db_models/updates.py index a3105305..f1e28b1b 100644 --- a/src/vr/db_models/updates.py +++ b/src/vr/db_models/updates.py @@ -42,6 +42,7 @@ def createNewTables(app): else: fields.append(i[0]) new_fields = [ + {"name": "settings_initialized", "type": "BOOLEAN", "default": 0}, {"name": "APP_EXT_URL", "type": "VARCHAR", "char_num": 200}, {"name": "AUTH_TYPE", "type": "VARCHAR", "char_num": 200}, {"name": "AZAD_AUTHORITY", "type": "VARCHAR", "char_num": 200}, @@ -85,10 +86,14 @@ def createNewTables(app): if app.config['RUNTIME_ENV'] == 'test': if i['type'] == 'VARCHAR': var_stmt = f"VARCHAR({i['char_num']})" + elif i['type'] == 'BOOLEAN': + var_stmt = f"BOOLEAN DEFAULT {i['default']}" sql = "ALTER TABLE AppConfig ADD COLUMN " + i['name'] + " " + var_stmt else: if i['type'] == 'VARCHAR': var_stmt = "TEXT" + elif i['type'] == 'BOOLEAN': + var_stmt = f"BOOLEAN DEFAULT {i['default']}" sql = "ALTER TABLE AppConfig ADD COLUMN " + i['name'] + " " + var_stmt cur.execute(sql) db.commit() From 7d1b0538ee2addbb374165c22801110f25029fde Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Mon, 18 Mar 2024 07:43:53 -0700 Subject: [PATCH 070/197] Release/0.1.0 beta/prod azure (#514) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile * Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * Feature/update settings function (#501) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * Feature/update release based db settings (#503) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * Feature/update release based db settings (#505) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#507) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#509) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Feature/fix syntax error (#511) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Feature/fix syntax error (#513) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py --- src/vr/db_models/updates.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vr/db_models/updates.py b/src/vr/db_models/updates.py index a3105305..f1e28b1b 100644 --- a/src/vr/db_models/updates.py +++ b/src/vr/db_models/updates.py @@ -42,6 +42,7 @@ def createNewTables(app): else: fields.append(i[0]) new_fields = [ + {"name": "settings_initialized", "type": "BOOLEAN", "default": 0}, {"name": "APP_EXT_URL", "type": "VARCHAR", "char_num": 200}, {"name": "AUTH_TYPE", "type": "VARCHAR", "char_num": 200}, {"name": "AZAD_AUTHORITY", "type": "VARCHAR", "char_num": 200}, @@ -85,10 +86,14 @@ def createNewTables(app): if app.config['RUNTIME_ENV'] == 'test': if i['type'] == 'VARCHAR': var_stmt = f"VARCHAR({i['char_num']})" + elif i['type'] == 'BOOLEAN': + var_stmt = f"BOOLEAN DEFAULT {i['default']}" sql = "ALTER TABLE AppConfig ADD COLUMN " + i['name'] + " " + var_stmt else: if i['type'] == 'VARCHAR': var_stmt = "TEXT" + elif i['type'] == 'BOOLEAN': + var_stmt = f"BOOLEAN DEFAULT {i['default']}" sql = "ALTER TABLE AppConfig ADD COLUMN " + i['name'] + " " + var_stmt cur.execute(sql) db.commit() From 7db0df8feb1932dfb4119a86a90ff5c5db558381 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 19 Mar 2024 19:12:02 -0700 Subject: [PATCH 071/197] Update settings.py --- src/vr/admin/routes/settings.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/vr/admin/routes/settings.py b/src/vr/admin/routes/settings.py index a3125e54..fea3e3b5 100644 --- a/src/vr/admin/routes/settings.py +++ b/src/vr/admin/routes/settings.py @@ -44,7 +44,7 @@ def settings(): AppConfig.AZAD_CLIENT_ID: all["AZAD_CLIENT_ID"], AppConfig.AZAD_CLIENT_SECRET: all["AZAD_CLIENT_SECRET"], AppConfig.AZURE_KEYVAULT_NAME: all["AZURE_KEYVAULT_NAME"], - AppConfig.ENV: all["ENV"], + AppConfig.ENV: ENV, AppConfig.INSECURE_OAUTH: all["INSECURE_OAUTH"], AppConfig.JENKINS_HOST: all["JENKINS_HOST"], AppConfig.JENKINS_KEY: all["JENKINS_KEY"], @@ -71,7 +71,7 @@ def settings(): AppConfig.SNOW_INSTANCE_NAME: all["SNOW_INSTANCE_NAME"], AppConfig.SNOW_PASSWORD: all["SNOW_PASSWORD"], AppConfig.SNOW_USERNAME: all["SNOW_USERNAME"], - AppConfig.VERSION: all["VERSION"], + AppConfig.VERSION: VERSION, } if not app_config.settings_initialized: update_json[AppConfig.settings_initialized] = True @@ -88,7 +88,7 @@ def settings(): "AZAD_CLIENT_ID": all["AZAD_CLIENT_ID"], "AZAD_CLIENT_SECRET": all["AZAD_CLIENT_SECRET"], "AZURE_KEYVAULT_NAME": all["AZURE_KEYVAULT_NAME"], - "ENV": all["ENV"], + "ENV": ENV, "INSECURE_OAUTH": all["INSECURE_OAUTH"], "JENKINS_HOST": all["JENKINS_HOST"], "JENKINS_KEY": all["JENKINS_KEY"], @@ -115,7 +115,7 @@ def settings(): "SNOW_INSTANCE_NAME": all["SNOW_INSTANCE_NAME"], "SNOW_PASSWORD": all["SNOW_PASSWORD"], "SNOW_USERNAME": all["SNOW_USERNAME"], - "VERSION": all["VERSION"], + "VERSION": VERSION, } else: app_config = AppConfig.query.first() @@ -257,7 +257,7 @@ def set_env_variables(form): os.environ['AZAD_CLIENT_ID'] = form["AZAD_CLIENT_ID"] os.environ['AZAD_CLIENT_SECRET'] = form["AZAD_CLIENT_SECRET"] os.environ['AZURE_KEYVAULT_NAME'] = form["AZURE_KEYVAULT_NAME"] - os.environ['ENV'] = form["ENV"] + os.environ['ENV'] = ENV os.environ['INSECURE_OAUTH'] = form["INSECURE_OAUTH"] os.environ['JENKINS_ENABLED'] = form["JENKINS_ENABLED"] os.environ['JENKINS_HOST'] = form["JENKINS_HOST"] @@ -286,7 +286,7 @@ def set_env_variables(form): os.environ['SNOW_INSTANCE_NAME'] = form["SNOW_INSTANCE_NAME"] os.environ['SNOW_PASSWORD'] = form["SNOW_PASSWORD"] os.environ['SNOW_USERNAME'] = form["SNOW_USERNAME"] - os.environ['VERSION'] = form["VERSION"] + os.environ['VERSION'] = VERSION @admin.route('/dangerous/delete_all', methods=['POST']) From f98f329338401f961c310188ae205e5b0aec2b1d Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 19 Mar 2024 19:24:16 -0700 Subject: [PATCH 072/197] Feature/fix syntax error (#515) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py --- src/vr/admin/routes/settings.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/vr/admin/routes/settings.py b/src/vr/admin/routes/settings.py index a3125e54..fea3e3b5 100644 --- a/src/vr/admin/routes/settings.py +++ b/src/vr/admin/routes/settings.py @@ -44,7 +44,7 @@ def settings(): AppConfig.AZAD_CLIENT_ID: all["AZAD_CLIENT_ID"], AppConfig.AZAD_CLIENT_SECRET: all["AZAD_CLIENT_SECRET"], AppConfig.AZURE_KEYVAULT_NAME: all["AZURE_KEYVAULT_NAME"], - AppConfig.ENV: all["ENV"], + AppConfig.ENV: ENV, AppConfig.INSECURE_OAUTH: all["INSECURE_OAUTH"], AppConfig.JENKINS_HOST: all["JENKINS_HOST"], AppConfig.JENKINS_KEY: all["JENKINS_KEY"], @@ -71,7 +71,7 @@ def settings(): AppConfig.SNOW_INSTANCE_NAME: all["SNOW_INSTANCE_NAME"], AppConfig.SNOW_PASSWORD: all["SNOW_PASSWORD"], AppConfig.SNOW_USERNAME: all["SNOW_USERNAME"], - AppConfig.VERSION: all["VERSION"], + AppConfig.VERSION: VERSION, } if not app_config.settings_initialized: update_json[AppConfig.settings_initialized] = True @@ -88,7 +88,7 @@ def settings(): "AZAD_CLIENT_ID": all["AZAD_CLIENT_ID"], "AZAD_CLIENT_SECRET": all["AZAD_CLIENT_SECRET"], "AZURE_KEYVAULT_NAME": all["AZURE_KEYVAULT_NAME"], - "ENV": all["ENV"], + "ENV": ENV, "INSECURE_OAUTH": all["INSECURE_OAUTH"], "JENKINS_HOST": all["JENKINS_HOST"], "JENKINS_KEY": all["JENKINS_KEY"], @@ -115,7 +115,7 @@ def settings(): "SNOW_INSTANCE_NAME": all["SNOW_INSTANCE_NAME"], "SNOW_PASSWORD": all["SNOW_PASSWORD"], "SNOW_USERNAME": all["SNOW_USERNAME"], - "VERSION": all["VERSION"], + "VERSION": VERSION, } else: app_config = AppConfig.query.first() @@ -257,7 +257,7 @@ def set_env_variables(form): os.environ['AZAD_CLIENT_ID'] = form["AZAD_CLIENT_ID"] os.environ['AZAD_CLIENT_SECRET'] = form["AZAD_CLIENT_SECRET"] os.environ['AZURE_KEYVAULT_NAME'] = form["AZURE_KEYVAULT_NAME"] - os.environ['ENV'] = form["ENV"] + os.environ['ENV'] = ENV os.environ['INSECURE_OAUTH'] = form["INSECURE_OAUTH"] os.environ['JENKINS_ENABLED'] = form["JENKINS_ENABLED"] os.environ['JENKINS_HOST'] = form["JENKINS_HOST"] @@ -286,7 +286,7 @@ def set_env_variables(form): os.environ['SNOW_INSTANCE_NAME'] = form["SNOW_INSTANCE_NAME"] os.environ['SNOW_PASSWORD'] = form["SNOW_PASSWORD"] os.environ['SNOW_USERNAME'] = form["SNOW_USERNAME"] - os.environ['VERSION'] = form["VERSION"] + os.environ['VERSION'] = VERSION @admin.route('/dangerous/delete_all', methods=['POST']) From 9a9b91d986e2b6f7ee1f6139fc227646a195a66f Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Tue, 19 Mar 2024 19:24:41 -0700 Subject: [PATCH 073/197] Release/0.1.0 beta/prod azure (#516) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile * Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * Feature/update settings function (#501) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * Feature/update release based db settings (#503) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * Feature/update release based db settings (#505) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#507) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#509) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Feature/fix syntax error (#511) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Feature/fix syntax error (#513) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Feature/fix syntax error (#515) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py --- src/vr/admin/routes/settings.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/vr/admin/routes/settings.py b/src/vr/admin/routes/settings.py index a3125e54..fea3e3b5 100644 --- a/src/vr/admin/routes/settings.py +++ b/src/vr/admin/routes/settings.py @@ -44,7 +44,7 @@ def settings(): AppConfig.AZAD_CLIENT_ID: all["AZAD_CLIENT_ID"], AppConfig.AZAD_CLIENT_SECRET: all["AZAD_CLIENT_SECRET"], AppConfig.AZURE_KEYVAULT_NAME: all["AZURE_KEYVAULT_NAME"], - AppConfig.ENV: all["ENV"], + AppConfig.ENV: ENV, AppConfig.INSECURE_OAUTH: all["INSECURE_OAUTH"], AppConfig.JENKINS_HOST: all["JENKINS_HOST"], AppConfig.JENKINS_KEY: all["JENKINS_KEY"], @@ -71,7 +71,7 @@ def settings(): AppConfig.SNOW_INSTANCE_NAME: all["SNOW_INSTANCE_NAME"], AppConfig.SNOW_PASSWORD: all["SNOW_PASSWORD"], AppConfig.SNOW_USERNAME: all["SNOW_USERNAME"], - AppConfig.VERSION: all["VERSION"], + AppConfig.VERSION: VERSION, } if not app_config.settings_initialized: update_json[AppConfig.settings_initialized] = True @@ -88,7 +88,7 @@ def settings(): "AZAD_CLIENT_ID": all["AZAD_CLIENT_ID"], "AZAD_CLIENT_SECRET": all["AZAD_CLIENT_SECRET"], "AZURE_KEYVAULT_NAME": all["AZURE_KEYVAULT_NAME"], - "ENV": all["ENV"], + "ENV": ENV, "INSECURE_OAUTH": all["INSECURE_OAUTH"], "JENKINS_HOST": all["JENKINS_HOST"], "JENKINS_KEY": all["JENKINS_KEY"], @@ -115,7 +115,7 @@ def settings(): "SNOW_INSTANCE_NAME": all["SNOW_INSTANCE_NAME"], "SNOW_PASSWORD": all["SNOW_PASSWORD"], "SNOW_USERNAME": all["SNOW_USERNAME"], - "VERSION": all["VERSION"], + "VERSION": VERSION, } else: app_config = AppConfig.query.first() @@ -257,7 +257,7 @@ def set_env_variables(form): os.environ['AZAD_CLIENT_ID'] = form["AZAD_CLIENT_ID"] os.environ['AZAD_CLIENT_SECRET'] = form["AZAD_CLIENT_SECRET"] os.environ['AZURE_KEYVAULT_NAME'] = form["AZURE_KEYVAULT_NAME"] - os.environ['ENV'] = form["ENV"] + os.environ['ENV'] = ENV os.environ['INSECURE_OAUTH'] = form["INSECURE_OAUTH"] os.environ['JENKINS_ENABLED'] = form["JENKINS_ENABLED"] os.environ['JENKINS_HOST'] = form["JENKINS_HOST"] @@ -286,7 +286,7 @@ def set_env_variables(form): os.environ['SNOW_INSTANCE_NAME'] = form["SNOW_INSTANCE_NAME"] os.environ['SNOW_PASSWORD'] = form["SNOW_PASSWORD"] os.environ['SNOW_USERNAME'] = form["SNOW_USERNAME"] - os.environ['VERSION'] = form["VERSION"] + os.environ['VERSION'] = VERSION @admin.route('/dangerous/delete_all', methods=['POST']) From 1e5bddf41c725c48117442ce88cd6b6b365f46a3 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 07:48:03 -0700 Subject: [PATCH 074/197] update to settings update without restart --- src/config_engine.py | 430 +++++++++++----------- src/vr/__init__.py | 102 +++-- src/vr/admin/auth_functions.py | 4 +- src/vr/admin/email_alerts.py | 8 +- src/vr/admin/models.py | 9 +- src/vr/admin/routes/forgotpw.py | 3 +- src/vr/admin/routes/forgotun.py | 3 +- src/vr/admin/routes/login.py | 15 +- src/vr/admin/routes/logout.py | 6 +- src/vr/admin/routes/register.py | 3 +- src/vr/admin/routes/settings.py | 130 ++++--- src/vr/admin/routes/users.py | 3 +- src/vr/api/integrations/servicenow.py | 13 +- src/vr/api/vulns/jenkins_webhook.py | 6 +- src/vr/api/vulns/vulnerabilities.py | 3 +- src/vr/db_models/setup.py | 9 +- src/vr/db_models/setup_2.py | 4 +- src/vr/orchestration/web/pipeline_jobs.py | 7 +- src/vr/templates/admin/settings.html | 12 +- src/vr/vulns/web/findings.py | 3 +- src/vr/vulns/web/testing.py | 8 +- 21 files changed, 420 insertions(+), 361 deletions(-) diff --git a/src/config_engine.py b/src/config_engine.py index 07400d06..7ee859ad 100644 --- a/src/config_engine.py +++ b/src/config_engine.py @@ -14,98 +14,229 @@ from settings import SET_SNOW_INSTANCE_NAME, SET_SNOW_CLIENT_ID, SET_SNOW_CLIENT_SECRET, SET_SNOW_USERNAME, SET_SNOW_PASSWORD, SET_SNOW_CLIENT_SECRET_REF, SET_SNOW_PASSWORD_REF -VERSION = '0.1.0-beta' - -if os.getenv('AZURE_KEYVAULT_NAME'): - AZURE_KEYVAULT_NAME = os.getenv('AZURE_KEYVAULT_NAME') -else: - AZURE_KEYVAULT_NAME = SET_AZURE_KEYVAULT_NAME - -if os.getenv('AUTH_TYPE'): - AUTH_TYPE = os.getenv('AUTH_TYPE') -else: - AUTH_TYPE = SET_AUTH_TYPE - -if os.getenv('INSECURE_OAUTH'): - INSECURE_OAUTH = os.getenv('INSECURE_OAUTH') -else: - INSECURE_OAUTH = SET_INSECURE_OAUTH - -if INSECURE_OAUTH: - os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1' - -if os.getenv('APP_EXT_URL'): - APP_EXT_URL = os.getenv('APP_EXT_URL') -else: - APP_EXT_URL = SET_APP_EXT_URL - -if os.getenv('SMTP_HOST'): - SMTP_HOST = os.getenv('SMTP_HOST') -else: - SMTP_HOST = SET_SMTP_HOST - -if os.getenv('SMTP_USER'): - SMTP_USER = os.getenv('SMTP_USER') -else: - SMTP_USER = SET_SMTP_USER - -if os.getenv('SMTP_ADMIN_EMAIL'): - SMTP_ADMIN_EMAIL = os.getenv('SMTP_ADMIN_EMAIL') -else: - SMTP_ADMIN_EMAIL = SET_SMTP_ADMIN_EMAIL - -if os.getenv('LDAP_HOST'): - LDAP_HOST = os.getenv('LDAP_HOST') -else: - LDAP_HOST = SET_LDAP_HOST - -if os.getenv('LDAP_PORT'): - LDAP_PORT = os.getenv('LDAP_PORT') -else: - LDAP_PORT = SET_LDAP_PORT - -if os.getenv('LDAP_BASE_DN'): - LDAP_BASE_DN = os.getenv('LDAP_BASE_DN') -else: - LDAP_BASE_DN = SET_LDAP_BASE_DN - -if os.getenv('LDAP_USER_DN'): - LDAP_USER_DN = os.getenv('LDAP_USER_DN') -else: - LDAP_USER_DN = SET_LDAP_USER_DN - -if os.getenv('LDAP_GROUP_DN'): - LDAP_GROUP_DN = os.getenv('LDAP_GROUP_DN') -else: - LDAP_GROUP_DN = SET_LDAP_GROUP_DN - -if os.getenv('LDAP_USER_RDN_ATTR'): - LDAP_USER_RDN_ATTR = os.getenv('LDAP_USER_RDN_ATTR') -else: - LDAP_USER_RDN_ATTR = SET_LDAP_USER_RDN_ATTR - -if os.getenv('LDAP_USER_LOGIN_ATTR'): - LDAP_USER_LOGIN_ATTR = os.getenv('LDAP_USER_LOGIN_ATTR') -else: - LDAP_USER_LOGIN_ATTR = SET_LDAP_USER_LOGIN_ATTR - -if os.getenv('LDAP_BIND_USER_DN'): - LDAP_BIND_USER_DN = os.getenv('LDAP_BIND_USER_DN') -else: - LDAP_BIND_USER_DN = SET_LDAP_BIND_USER_DN - -if os.getenv('LDAP_BIND_USER_PASSWORD'): - LDAP_BIND_USER_PASSWORD = os.getenv('LDAP_BIND_USER_PASSWORD') -else: - LDAP_BIND_USER_PASSWORD = SET_LDAP_BIND_USER_PASSWORD +def getConfigs(config): + config['TEST_SETTING'] = 'set' + + config['VERSION'] = '0.1.0-beta' + + if os.getenv('AZURE_KEYVAULT_NAME'): + config['AZURE_KEYVAULT_NAME'] = os.getenv('AZURE_KEYVAULT_NAME') + else: + config['AZURE_KEYVAULT_NAME'] = SET_AZURE_KEYVAULT_NAME + + if os.getenv('AUTH_TYPE'): + config['AUTH_TYPE'] = os.getenv('AUTH_TYPE') + else: + config['AUTH_TYPE'] = SET_AUTH_TYPE + + if os.getenv('INSECURE_OAUTH'): + config['INSECURE_OAUTH'] = os.getenv('INSECURE_OAUTH') + else: + config['INSECURE_OAUTH'] = SET_INSECURE_OAUTH + + if config['INSECURE_OAUTH']: + os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1' + + if os.getenv('APP_EXT_URL'): + config['APP_EXT_URL'] = os.getenv('APP_EXT_URL') + else: + config['APP_EXT_URL'] = SET_APP_EXT_URL + + if os.getenv('SMTP_HOST'): + config['SMTP_HOST'] = os.getenv('SMTP_HOST') + else: + config['SMTP_HOST'] = SET_SMTP_HOST + + if os.getenv('SMTP_USER'): + config['SMTP_USER'] = os.getenv('SMTP_USER') + else: + config['SMTP_USER'] = SET_SMTP_USER + + if os.getenv('SMTP_ADMIN_EMAIL'): + config['SMTP_ADMIN_EMAIL'] = os.getenv('SMTP_ADMIN_EMAIL') + else: + config['SMTP_ADMIN_EMAIL'] = SET_SMTP_ADMIN_EMAIL + + if os.getenv('LDAP_HOST'): + config['LDAP_HOST'] = os.getenv('LDAP_HOST') + else: + config['LDAP_HOST'] = SET_LDAP_HOST + + if os.getenv('LDAP_PORT'): + config['LDAP_PORT'] = os.getenv('LDAP_PORT') + else: + config['LDAP_PORT'] = SET_LDAP_PORT + + if os.getenv('LDAP_BASE_DN'): + config['LDAP_BASE_DN'] = os.getenv('LDAP_BASE_DN') + else: + config['LDAP_BASE_DN'] = SET_LDAP_BASE_DN + + if os.getenv('LDAP_USER_DN'): + config['LDAP_USER_DN'] = os.getenv('LDAP_USER_DN') + else: + config['LDAP_USER_DN'] = SET_LDAP_USER_DN + + if os.getenv('LDAP_GROUP_DN'): + config['LDAP_GROUP_DN'] = os.getenv('LDAP_GROUP_DN') + else: + config['LDAP_GROUP_DN'] = SET_LDAP_GROUP_DN + + if os.getenv('LDAP_USER_RDN_ATTR'): + config['LDAP_USER_RDN_ATTR'] = os.getenv('LDAP_USER_RDN_ATTR') + else: + config['LDAP_USER_RDN_ATTR'] = SET_LDAP_USER_RDN_ATTR + + if os.getenv('LDAP_USER_LOGIN_ATTR'): + config['LDAP_USER_LOGIN_ATTR'] = os.getenv('LDAP_USER_LOGIN_ATTR') + else: + config['LDAP_USER_LOGIN_ATTR'] = SET_LDAP_USER_LOGIN_ATTR + + if os.getenv('LDAP_BIND_USER_DN'): + config['LDAP_BIND_USER_DN'] = os.getenv('LDAP_BIND_USER_DN') + else: + config['LDAP_BIND_USER_DN'] = SET_LDAP_BIND_USER_DN + + if os.getenv('LDAP_BIND_USER_PASSWORD'): + config['LDAP_BIND_USER_PASSWORD'] = os.getenv('LDAP_BIND_USER_PASSWORD') + else: + config['LDAP_BIND_USER_PASSWORD'] = SET_LDAP_BIND_USER_PASSWORD + + ## CORE Config Variables ## + if os.getenv('ENV'): + config['ENV'] = os.getenv('ENV') + else: + config['ENV'] = SET_ENV + + if config['ENV'] == 'prod': + if os.getenv('PROD_DB_URI_REF'): + config['PROD_DB_URI'] = KeyVaultManager(config).get_secret(os.getenv('PROD_DB_URI_REF')) + else: + config['PROD_DB_URI'] = KeyVaultManager(config).get_secret(SET_PROD_DB_URI_REF) + else: + config['PROD_DB_URI'] = SET_PROD_DB_URI + + if config['AUTH_TYPE'] == 'azuread': + if os.getenv('AZAD_CLIENT_ID'): + config['AZAD_CLIENT_ID'] = os.getenv('AZAD_CLIENT_ID') + else: + config['AZAD_CLIENT_ID'] = SET_AZAD_CLIENT_ID + if os.getenv('AZAD_CLIENT_SECRET'): + config['AZAD_CLIENT_SECRET'] = KeyVaultManager(config).get_secret(os.getenv('AZAD_CLIENT_SECRET')) + else: + config['AZAD_CLIENT_SECRET'] = KeyVaultManager(config).get_secret(SET_AZAD_CLIENT_SECRET) + if os.getenv('AZAD_AUTHORITY'): + config['AZAD_AUTHORITY'] = os.getenv('AZAD_AUTHORITY') + else: + config['AZAD_AUTHORITY'] = SET_AZAD_AUTHORITY + else: + config['AZAD_CLIENT_ID'] = "" + config['AZAD_CLIENT_SECRET'] = "" + config['AZAD_AUTHORITY'] = "" + + ## Email Variables ## + if config['ENV'] == 'prod': + if os.getenv('SMTP_PW_REF'): + config['SMTP_PASSWORD'] = KeyVaultManager(config).get_secret(os.getenv('SMTP_PW_REF')) + else: + config['SMTP_PASSWORD'] = KeyVaultManager(config).get_secret(SET_SMTP_PW_REF) + else: + config['SMTP_PASSWORD'] = SET_SMTP_PW + + ## + ## GitHub to Jenkins Webhook ## + if os.getenv('JENKINS_ENABLED'): + config['JENKINS_ENABLED'] = os.getenv('JENKINS_ENABLED') + else: + config['JENKINS_ENABLED'] = SET_JENKINS_ENABLED + if config['JENKINS_ENABLED'] == 'yes': + if config['ENV'] == 'prod': + if os.getenv('JENKINS_USER'): + config['JENKINS_USER'] = KeyVaultManager(config).get_secret(os.getenv('JENKINS_USER')) + else: + config['JENKINS_USER'] = KeyVaultManager(config).get_secret(SET_JENKINS_USER_REF) + if os.getenv('JENKINS_KEY'): + config['JENKINS_KEY'] = KeyVaultManager(config).get_secret(os.getenv('JENKINS_KEY')) + else: + config['JENKINS_KEY'] = KeyVaultManager(config).get_secret(SET_JENKINS_KEY_REF) + if os.getenv('JENKINS_TOKEN'): + config['JENKINS_TOKEN'] = KeyVaultManager(config).get_secret(os.getenv('JENKINS_TOKEN')) + else: + config['JENKINS_TOKEN'] = KeyVaultManager(config).get_secret(SET_JENKINS_TOKEN_REF) + else: + config['JENKINS_USER'] = SET_JENKINS_USER + config['JENKINS_KEY'] = SET_JENKINS_KEY + config['JENKINS_TOKEN'] = SET_JENKINS_TOKEN + + if os.getenv('JENKINS_PROJECT'): + config['JENKINS_PROJECT'] = os.getenv('JENKINS_PROJECT') + else: + config['JENKINS_PROJECT'] = SET_JENKINS_PROJECT + + if os.getenv('JENKINS_HOST'): + config['JENKINS_HOST'] = os.getenv('JENKINS_HOST') + else: + config['JENKINS_HOST'] = SET_JENKINS_HOST + + if os.getenv('JENKINS_STAGING_PROJECT'): + config['JENKINS_STAGING_PROJECT'] = os.getenv('JENKINS_STAGING_PROJECT') + else: + config['JENKINS_STAGING_PROJECT'] = SET_JENKINS_STAGING_PROJECT + else: + config['JENKINS_USER'] = "" + config['JENKINS_KEY'] = "" + config['JENKINS_TOKEN'] = "" + config['JENKINS_PROJECT'] = "" + config['JENKINS_HOST'] = "" + config['JENKINS_STAGING_PROJECT'] = "" + + ## ServiceNOW Integration + if os.getenv('SNOW_ENABLED'): + config['SNOW_ENABLED'] = os.getenv('SNOW_ENABLED') + else: + config['SNOW_ENABLED'] = SET_SNOW_ENABLED + if config['SNOW_ENABLED'] == 'yes': + if config['ENV'] == 'prod': + if os.getenv('SNOW_PASSWORD'): + config['SNOW_PASSWORD'] = KeyVaultManager(config).get_secret(os.getenv('SNOW_PASSWORD')) + else: + config['SNOW_PASSWORD'] = KeyVaultManager(config).get_secret(SET_SNOW_PASSWORD_REF) + if os.getenv('SNOW_CLIENT_SECRET'): + config['SNOW_CLIENT_SECRET'] = KeyVaultManager(config).get_secret(os.getenv('SNOW_CLIENT_SECRET')) + else: + config['SNOW_CLIENT_SECRET'] = KeyVaultManager(config).get_secret(SET_SNOW_CLIENT_SECRET_REF) + if os.getenv('SNOW_INSTANCE_NAME'): + config['SNOW_INSTANCE_NAME'] = os.getenv('SNOW_INSTANCE_NAME') + else: + config['SNOW_INSTANCE_NAME'] = SET_SNOW_INSTANCE_NAME + if os.getenv('SNOW_CLIENT_ID'): + config['SNOW_CLIENT_ID'] = os.getenv('SNOW_CLIENT_ID') + else: + config['SNOW_CLIENT_ID'] = SET_SNOW_CLIENT_ID + if os.getenv('SNOW_USERNAME'): + config['SNOW_USERNAME'] = os.getenv('SNOW_USERNAME') + else: + config['SNOW_USERNAME'] = SET_SNOW_USERNAME + else: + config['SNOW_PASSWORD'] = SET_SNOW_PASSWORD + config['SNOW_CLIENT_SECRET'] = SET_SNOW_CLIENT_SECRET + config['SNOW_INSTANCE_NAME'] = SET_SNOW_INSTANCE_NAME + config['SNOW_CLIENT_ID'] = SET_SNOW_CLIENT_ID + config['SNOW_USERNAME'] = SET_SNOW_USERNAME + else: + config['SNOW_PASSWORD'] = "" + config['SNOW_CLIENT_SECRET'] = "" + config['SNOW_INSTANCE_NAME'] = "" + config['SNOW_CLIENT_ID'] = "" + config['SNOW_USERNAME'] = "" class KeyVaultManager(object): - def __init__(self): + def __init__(self, config=None): if os.getenv('AZURE_KEYVAULT_NAME'): key_vault_uri = f"https://{os.getenv('AZURE_KEYVAULT_NAME')}.vault.azure.net" else: - key_vault_uri = f"https://{AZURE_KEYVAULT_NAME}.vault.azure.net" + key_vault_uri = f"https://{config['AZURE_KEYVAULT_NAME']}.vault.azure.net" if os.getenv('AZURE_AUTH_METHOD'): if os.getenv('AZURE_AUTH_METHOD') == 'env': self.credential = EnvironmentCredential( @@ -162,130 +293,3 @@ def delete_cert(self, secret_name): return deleted_secret -## CORE Config Variables ## -if os.getenv('ENV'): - ENV = os.getenv('ENV') -else: - ENV = SET_ENV - -if ENV == 'prod': - if os.getenv('PROD_DB_URI_REF'): - PROD_DB_URI = KeyVaultManager().get_secret(os.getenv('PROD_DB_URI_REF')) - else: - PROD_DB_URI = KeyVaultManager().get_secret(SET_PROD_DB_URI_REF) -else: - PROD_DB_URI = SET_PROD_DB_URI - -if AUTH_TYPE == 'azuread': - if os.getenv('AZAD_CLIENT_ID'): - AZAD_CLIENT_ID = os.getenv('AZAD_CLIENT_ID') - else: - AZAD_CLIENT_ID = SET_AZAD_CLIENT_ID - if os.getenv('AZAD_CLIENT_SECRET'): - AZAD_CLIENT_SECRET = KeyVaultManager().get_secret(os.getenv('AZAD_CLIENT_SECRET')) - else: - AZAD_CLIENT_SECRET = KeyVaultManager().get_secret(SET_AZAD_CLIENT_SECRET) - if os.getenv('AZAD_AUTHORITY'): - AZAD_AUTHORITY = os.getenv('AZAD_AUTHORITY') - else: - AZAD_AUTHORITY = SET_AZAD_AUTHORITY -else: - AZAD_CLIENT_ID = "" - AZAD_CLIENT_SECRET = "" - AZAD_AUTHORITY = "" - -## Email Variables ## -if ENV == 'prod': - if os.getenv('SMTP_PW_REF'): - SMTP_PASSWORD = KeyVaultManager().get_secret(os.getenv('SMTP_PW_REF')) - else: - SMTP_PASSWORD = KeyVaultManager().get_secret(SET_SMTP_PW_REF) -else: - SMTP_PASSWORD = SET_SMTP_PW - -## -## GitHub to Jenkins Webhook ## -if os.getenv('JENKINS_ENABLED'): - JENKINS_ENABLED = os.getenv('JENKINS_ENABLED') -else: - JENKINS_ENABLED = SET_JENKINS_ENABLED -if JENKINS_ENABLED == 'yes': - if ENV == 'prod': - if os.getenv('JENKINS_USER'): - JENKINS_USER = KeyVaultManager().get_secret(os.getenv('JENKINS_USER')) - else: - JENKINS_USER = KeyVaultManager().get_secret(SET_JENKINS_USER_REF) - if os.getenv('JENKINS_KEY'): - JENKINS_KEY = KeyVaultManager().get_secret(os.getenv('JENKINS_KEY')) - else: - JENKINS_KEY = KeyVaultManager().get_secret(SET_JENKINS_KEY_REF) - if os.getenv('JENKINS_TOKEN'): - JENKINS_TOKEN = KeyVaultManager().get_secret(os.getenv('JENKINS_TOKEN')) - else: - JENKINS_TOKEN = KeyVaultManager().get_secret(SET_JENKINS_TOKEN_REF) - else: - JENKINS_USER = SET_JENKINS_USER - JENKINS_KEY = SET_JENKINS_KEY - JENKINS_TOKEN = SET_JENKINS_TOKEN - - if os.getenv('JENKINS_PROJECT'): - JENKINS_PROJECT = os.getenv('JENKINS_PROJECT') - else: - JENKINS_PROJECT = SET_JENKINS_PROJECT - - if os.getenv('JENKINS_HOST'): - JENKINS_HOST = os.getenv('JENKINS_HOST') - else: - JENKINS_HOST = SET_JENKINS_HOST - - if os.getenv('JENKINS_STAGING_PROJECT'): - JENKINS_STAGING_PROJECT = os.getenv('JENKINS_STAGING_PROJECT') - else: - JENKINS_STAGING_PROJECT = SET_JENKINS_STAGING_PROJECT -else: - JENKINS_USER = "" - JENKINS_KEY = "" - JENKINS_TOKEN = "" - JENKINS_PROJECT = "" - JENKINS_HOST = "" - JENKINS_STAGING_PROJECT = "" - -## ServiceNOW Integration -if os.getenv('SNOW_ENABLED'): - SNOW_ENABLED = os.getenv('SNOW_ENABLED') -else: - SNOW_ENABLED = SET_SNOW_ENABLED -if SNOW_ENABLED == 'yes': - if ENV == 'prod': - if os.getenv('SNOW_PASSWORD'): - SNOW_PASSWORD = KeyVaultManager().get_secret(os.getenv('SNOW_PASSWORD')) - else: - SNOW_PASSWORD = KeyVaultManager().get_secret(SET_SNOW_PASSWORD_REF) - if os.getenv('SNOW_CLIENT_SECRET'): - SNOW_CLIENT_SECRET = KeyVaultManager().get_secret(os.getenv('SNOW_CLIENT_SECRET')) - else: - SNOW_CLIENT_SECRET = KeyVaultManager().get_secret(SET_SNOW_CLIENT_SECRET_REF) - if os.getenv('SNOW_INSTANCE_NAME'): - SNOW_INSTANCE_NAME = os.getenv('SNOW_INSTANCE_NAME') - else: - SNOW_INSTANCE_NAME = SET_SNOW_INSTANCE_NAME - if os.getenv('SNOW_CLIENT_ID'): - SNOW_CLIENT_ID = os.getenv('SNOW_CLIENT_ID') - else: - SNOW_CLIENT_ID = SET_SNOW_CLIENT_ID - if os.getenv('SNOW_USERNAME'): - SNOW_USERNAME = os.getenv('SNOW_USERNAME') - else: - SNOW_USERNAME = SET_SNOW_USERNAME - else: - SNOW_PASSWORD = SET_SNOW_PASSWORD - SNOW_CLIENT_SECRET = SET_SNOW_CLIENT_SECRET - SNOW_INSTANCE_NAME = SET_SNOW_INSTANCE_NAME - SNOW_CLIENT_ID = SET_SNOW_CLIENT_ID - SNOW_USERNAME = SET_SNOW_USERNAME -else: - SNOW_PASSWORD = "" - SNOW_CLIENT_SECRET = "" - SNOW_INSTANCE_NAME = "" - SNOW_CLIENT_ID = "" - SNOW_USERNAME = "" diff --git a/src/vr/__init__.py b/src/vr/__init__.py index 42a86ea1..2f3ccf73 100644 --- a/src/vr/__init__.py +++ b/src/vr/__init__.py @@ -1,8 +1,6 @@ import datetime import requests -from config_engine import ENV, PROD_DB_URI, AUTH_TYPE, APP_EXT_URL, LDAP_HOST, LDAP_PORT, LDAP_BASE_DN, \ - LDAP_USER_DN, LDAP_GROUP_DN, LDAP_USER_RDN_ATTR, LDAP_USER_LOGIN_ATTR, LDAP_BIND_USER_DN, LDAP_BIND_USER_PASSWORD, \ - AZAD_CLIENT_ID, AZAD_CLIENT_SECRET, AZAD_AUTHORITY, JENKINS_USER, JENKINS_ENABLED +from config_engine import getConfigs from flask import Flask from flask_bootstrap import Bootstrap from flask_login import LoginManager @@ -11,8 +9,7 @@ from flask_wtf.csrf import CSRFProtect from flaskext.markdown import Markdown from vr.db_models.setup import _init_db -if AUTH_TYPE == 'ldap': - from flask_ldap3_login import LDAP3LoginManager + import base64 import logging import sys @@ -31,48 +28,41 @@ from requests.auth import HTTPBasicAuth from vr.db_models.updates import createNewTables -if AUTH_TYPE == 'azuread': + +app = Flask(__name__) + +getConfigs(app.config) + +if app.config['AUTH_TYPE'] == 'azuread': from flask_session import Session import msal from flask import session, url_for +if app.config['AUTH_TYPE'] == 'ldap': + from flask_ldap3_login import LDAP3LoginManager -app = Flask(__name__) moment = Moment(app) Markdown(app) csrf = CSRFProtect(app) -app.config['APP_EXT_URL'] = APP_EXT_URL - -app.config['RUNTIME_ENV'] = ENV +app.config['RUNTIME_ENV'] = app.config['ENV'] if app.config['RUNTIME_ENV'] == 'test': DB_URI = 'sqlite:///database.db' import sqlite3 else: - DB_URI = PROD_DB_URI + DB_URI = app.config['PROD_DB_URI'] import mysql.connector app.config['SQLALCHEMY_DATABASE_URI'] = DB_URI app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False -if AUTH_TYPE == 'ldap': - # LDAP Configuration - app.config['LDAP_HOST'] = LDAP_HOST - app.config['LDAP_PORT'] = LDAP_PORT - app.config['LDAP_BASE_DN'] = LDAP_BASE_DN - app.config['LDAP_USER_DN'] = LDAP_USER_DN - app.config['LDAP_GROUP_DN'] = LDAP_GROUP_DN - app.config['LDAP_USER_RDN_ATTR'] = LDAP_USER_RDN_ATTR - app.config['LDAP_USER_LOGIN_ATTR'] = LDAP_USER_LOGIN_ATTR - app.config['LDAP_BIND_USER_DN'] = LDAP_BIND_USER_DN - app.config['LDAP_BIND_USER_PASSWORD'] = LDAP_BIND_USER_PASSWORD - +if app.config['AUTH_TYPE'] == 'ldap': # Flask-LDAP3-Login Manager ldap_manager = LDAP3LoginManager(app) -elif AUTH_TYPE == 'azuread': - app.config['CLIENT_ID'] = AZAD_CLIENT_ID - app.config['CLIENT_SECRET'] = AZAD_CLIENT_SECRET - app.config['AUTHORITY'] = AZAD_AUTHORITY +elif app.config['AUTH_TYPE'] == 'azuread': + app.config['CLIENT_ID'] = app.config['AZAD_CLIENT_ID'] + app.config['CLIENT_SECRET'] = app.config['AZAD_CLIENT_SECRET'] + app.config['AUTHORITY'] = app.config['AZAD_AUTHORITY'] app.config['REDIRECT_PATH'] = "/getAToken" app.config['ENDPOINT'] = 'https://graph.microsoft.com/v1.0/me/memberOf' app.config['SCOPE'] = ["User.ReadBasic.All", "Group.Read.All", "Application.Read.All"] @@ -151,7 +141,7 @@ def _get_token_from_cache(scope=None): app.register_blueprint(api) bootstrap = Bootstrap(app) -if AUTH_TYPE == 'local' or AUTH_TYPE == 'azuread': +if app.config['AUTH_TYPE'] == 'local' or app.config['AUTH_TYPE'] == 'azuread': login_manager.init_app(app) login_manager.login_view = 'admin.login' @@ -162,9 +152,10 @@ def _get_token_from_cache(scope=None): app.logger.addHandler(stdout_handler) + @app.template_filter('format_datetime') def format_datetime(value): - if ENV == 'test': + if app.config['ENV'] == 'test': try: formatted = datetime.datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f") except: @@ -185,6 +176,8 @@ def base64encode(value): createNewTables(app) ## Cronjob-like tasks section ## + + def train_model_every_six_hours(): scheduler = BackgroundScheduler() scheduler.add_job(train_model, 'interval', hours=6) @@ -220,6 +213,53 @@ def connect_to_db(): cur = db.cursor() return cur, db +def getPersistentConfig(): + try: + cur, db = connect_to_db() + sql = 'SELECT * FROM AppConfig WHERE 1=1' + cur.execute(sql) + row = cur.fetchone() + if row[2]: + app.config['APP_EXT_URL'] = row[3] + app.config['AUTH_TYPE'] = row[4] + app.config['AZAD_AUTHORITY'] = row[5] + app.config['AZAD_CLIENT_ID'] = row[6] + app.config['AZAD_CLIENT_SECRET'] = row[7] + app.config['AZURE_KEYVAULT_NAME'] = row[8] + app.config['ENV'] = row[9] + app.config['INSECURE_OAUTH'] = row[10] + app.config['JENKINS_ENABLED'] = row[37] + app.config['JENKINS_HOST'] = row[11] + app.config['JENKINS_KEY'] = row[12] + app.config['JENKINS_PROJECT'] = row[13] + app.config['JENKINS_STAGING_PROJECT'] = row[14] + app.config['JENKINS_TOKEN'] = row[15] + app.config['JENKINS_USER'] = row[16] + app.config['LDAP_BASE_DN'] = row[17] + app.config['LDAP_BIND_USER_DN'] = row[18] + app.config['LDAP_BIND_USER_PASSWORD'] = row[19] + app.config['LDAP_GROUP_DN'] = row[20] + app.config['LDAP_HOST'] = row[21] + app.config['LDAP_PORT'] = row[22] + app.config['LDAP_USER_DN'] = row[23] + app.config['LDAP_USER_LOGIN_ATTR'] = row[24] + app.config['LDAP_USER_RDN_ATTR'] = row[25] + app.config['PROD_DB_URI'] = row[26] + app.config['SMTP_ADMIN_EMAIL'] = row[27] + app.config['SMTP_HOST'] = row[28] + app.config['SMTP_PASSWORD'] = row[29] + app.config['SMTP_USER'] = row[30] + app.config['SNOW_ENABLED'] = row[38] + app.config['SNOW_CLIENT_ID'] = row[31] + app.config['SNOW_CLIENT_SECRET'] = row[32] + app.config['SNOW_INSTANCE_NAME'] = row[33] + app.config['SNOW_PASSWORD'] = row[34] + app.config['SNOW_USERNAME'] = row[35] + app.config['VERSION'] = row[36] + except: + print('AppConfig Database table is either unreachable or not setup.') + +getPersistentConfig() def train_model(): try: @@ -337,7 +377,7 @@ def rsa_long_decrypt(priv_obj, msg, length=256): def get_jenkins_data(): - user_check = JENKINS_USER + user_check = app.config['JENKINS_USER'] if user_check != 'changeme': app.logger.info('Getting Jenkins Data') cur, db = connect_to_db() @@ -452,5 +492,5 @@ def get_jenkins_data(): # Call the Jobs Here # train_model_every_six_hours() -if JENKINS_ENABLED == 'yes': +if app.config['JENKINS_ENABLED'] == 'yes': get_jenkins_data_every_hour() diff --git a/src/vr/admin/auth_functions.py b/src/vr/admin/auth_functions.py index 20ddf7ca..885020c6 100644 --- a/src/vr/admin/auth_functions.py +++ b/src/vr/admin/auth_functions.py @@ -1,7 +1,7 @@ import jwt from time import time from vr.functions.mysql_db import connect_to_db -from config_engine import ENV +from vr import app # Error handler @@ -49,7 +49,7 @@ def create_api_key(user_id, otp_secret, expires_in=2592000): def verify_api_key(token): try: cur, db = connect_to_db() - if ENV == 'test': + if app.config['ENV'] == 'test': sql = 'SELECT oc.user_id, u.is_admin FROM oauth2_client oc JOIN oauth2_token ot ON oc.client_id=ot.client_id JOIN User u ON oc.user_id=u.id WHERE ot.id=?' else: sql = 'SELECT oc.user_id, u.is_admin FROM oauth2_client oc JOIN oauth2_token ot ON oc.client_id=ot.client_id JOIN User u ON oc.user_id=u.id WHERE ot.id=%s' diff --git a/src/vr/admin/email_alerts.py b/src/vr/admin/email_alerts.py index a1c48da3..698b5138 100644 --- a/src/vr/admin/email_alerts.py +++ b/src/vr/admin/email_alerts.py @@ -1,7 +1,7 @@ import smtplib from email.mime import multipart from email.mime import text as mimetext -from config_engine import SMTP_HOST, SMTP_USER, SMTP_PASSWORD, SMTP_ADMIN_EMAIL +from vr import app def send_email(msg_fromaddr, msg_toaddr, msg_subject, msg_body): @@ -11,9 +11,9 @@ def send_email(msg_fromaddr, msg_toaddr, msg_subject, msg_body): msg['To'] = msg_toaddr msg['Subject'] = msg_subject msg.attach(mimetext.MIMEText(message, 'html')) - server = smtplib.SMTP(SMTP_HOST) + server = smtplib.SMTP(app.config['SMTP_HOST']) server.starttls() - server.login(SMTP_USER, SMTP_PASSWORD) + server.login(app.config['SMTP_USER'], app.config['SMTP_PASSWORD']) server.ehlo() text = msg.as_string() server.sendmail(msg_fromaddr, msg_toaddr, text) @@ -24,7 +24,7 @@ def send_registration_email(ext_url, username, first_name, last_name, token, ema msg_subject = "SecuSphere User Registration" msg_body = generate_registration_msg(ext_url, username, first_name, last_name, token) try: - send_email(SMTP_ADMIN_EMAIL, email_to, msg_subject, msg_body) + send_email(app.config['SMTP_ADMIN_EMAIL'], email_to, msg_subject, msg_body) except: return 'error' diff --git a/src/vr/admin/models.py b/src/vr/admin/models.py index 89785772..d5d5e4ad 100644 --- a/src/vr/admin/models.py +++ b/src/vr/admin/models.py @@ -3,7 +3,7 @@ from flask_login import UserMixin from vr import db, app from vr.functions.mysql_db import connect_to_db -from datetime import datetime, timedelta +from datetime import datetime import jwt from vr.admin.helper_functions import hash_password,verify_password from vr.admin.functions import db_connection_handler @@ -17,8 +17,7 @@ OAuth2AuthorizationCodeMixin, OAuth2TokenMixin, ) -from config_engine import AUTH_TYPE -if AUTH_TYPE == 'ldap': +if app.config['AUTH_TYPE'] == 'ldap': from vr import ldap_manager if app.config['RUNTIME_ENV'] == 'test': @@ -190,11 +189,11 @@ def verify_username_token(self, token, given_id): else: return -if AUTH_TYPE == 'local' or AUTH_TYPE == 'azuread': +if app.config['AUTH_TYPE'] == 'local' or app.config['AUTH_TYPE'] == 'azuread': @login_manager.user_loader def load_user(id): return User.query.get(int(id)) -elif AUTH_TYPE == 'ldap': +elif app.config['AUTH_TYPE'] == 'ldap': # User Loader for LDAP @login_manager.user_loader def load_user(user_id): diff --git a/src/vr/admin/routes/forgotpw.py b/src/vr/admin/routes/forgotpw.py index 2d12cd59..f6d50228 100644 --- a/src/vr/admin/routes/forgotpw.py +++ b/src/vr/admin/routes/forgotpw.py @@ -6,7 +6,6 @@ from vr.admin.email_alerts import send_email, generate_evnt_msg from vr.functions.timefunctions import return_datetime_now from vr.admin.helper_functions import hash_password -from config_engine import SMTP_ADMIN_EMAIL from vr.admin.functions import db_connection_handler @@ -32,7 +31,7 @@ def forgotpw(): action_list = [action] st = 'n' msg_body = generate_evnt_msg(msg_subject, now, evt_list, action_list, st) - msg_fromaddr = SMTP_ADMIN_EMAIL + msg_fromaddr = app.config['SMTP_ADMIN_EMAIL'] try: send_email(msg_fromaddr, email, msg_subject, msg_body) warnmsg = ('pwresetemail', 'success') diff --git a/src/vr/admin/routes/forgotun.py b/src/vr/admin/routes/forgotun.py index 80c52425..d8a0d2fa 100644 --- a/src/vr/admin/routes/forgotun.py +++ b/src/vr/admin/routes/forgotun.py @@ -5,7 +5,6 @@ from vr.admin.models import User, LoginForm from vr.admin.email_alerts import send_email, generate_evnt_msg from vr.functions.timefunctions import return_datetime_now -from config_engine import SMTP_ADMIN_EMAIL NAV_CAT= { "name": "Admin", "url": "admin.admin_dashboard"} @@ -28,7 +27,7 @@ def forgotun(): action_list = [action] st = 'n' msg_body = generate_evnt_msg(msg_subject,now,evt_list,action_list,st) - msg_fromaddr = SMTP_ADMIN_EMAIL + msg_fromaddr = app.config['SMTP_ADMIN_EMAIL'] try: send_email(msg_fromaddr, email, msg_subject, msg_body) warnmsg = ('pwresetemail', 'success') diff --git a/src/vr/admin/routes/login.py b/src/vr/admin/routes/login.py index 9eed58a7..d7f641f1 100644 --- a/src/vr/admin/routes/login.py +++ b/src/vr/admin/routes/login.py @@ -8,10 +8,9 @@ from vr.admin.models import User, LoginForm, AuthAttempts, AppConfig from vr.admin.functions import _auth_user, _entity_permissions_filter, _entity_page_permissions_filter, check_lockout, log_failed_attempt from vr.admin.functions import db_connection_handler -from config_engine import AUTH_TYPE -if AUTH_TYPE == 'ldap': +if app.config['AUTH_TYPE'] == 'ldap': from flask_ldap3_login.forms import LDAPLoginForm -elif AUTH_TYPE == 'azuread': +elif app.config['AUTH_TYPE'] == 'azuread': import requests import msal from vr import _build_auth_code_flow, _load_cache, _save_cache, _build_msal_app, _get_token_from_cache @@ -35,7 +34,7 @@ def login(): return redirect(url_for('admin.register')) ad_auth_url = None warnmsg = '' - if AUTH_TYPE == 'local': + if app.config['AUTH_TYPE'] == 'local': if current_user.is_authenticated: flash('You are already logged in.', 'danger') return redirect(url_for('assets.all_applications')) @@ -60,7 +59,7 @@ def login(): mfa_password = resp[2] # attempt to log the user in return _login_attempt(user, username, password, userid, form, mfa_password) - elif AUTH_TYPE == 'ldap': + elif app.config['AUTH_TYPE'] == 'ldap': form = LDAPLoginForm() if form.validate_on_submit(): # Log the user in @@ -71,15 +70,15 @@ def login(): # Print the form errors print("Form validation failed with errors:", form.errors) return render_template(LDAP_LOGIN_TEMPLATE, form=form, errors=form.errors) - elif AUTH_TYPE == 'azuread': + elif app.config['AUTH_TYPE'] == 'azuread': form = LoginForm(request.form) session["flow"] = _build_auth_code_flow(scopes=app.config['SCOPE']) ad_auth_url = session["flow"]["auth_uri"] if form.errors: warnmsg = (form.errors, 'danger') - return render_template(LOGIN_TEMPLATE, form=form, warnmsg=warnmsg, auth_type=AUTH_TYPE, auth_url=ad_auth_url) + return render_template(LOGIN_TEMPLATE, form=form, warnmsg=warnmsg, auth_type=app.config['AUTH_TYPE'], auth_url=ad_auth_url) -if AUTH_TYPE == 'azuread': +if app.config['AUTH_TYPE'] == 'azuread': @app.route(app.config['REDIRECT_PATH']) # Its absolute URL must match your app's redirect_uri set in AAD def authorized(): try: diff --git a/src/vr/admin/routes/logout.py b/src/vr/admin/routes/logout.py index 218cd357..781302c9 100644 --- a/src/vr/admin/routes/logout.py +++ b/src/vr/admin/routes/logout.py @@ -1,20 +1,20 @@ from flask_login import logout_user, login_required from flask import session, redirect, url_for from vr.admin import admin -from config_engine import AUTH_TYPE +from vr import app NAV_CAT= { "name": "Admin", "url": "admin.admin_dashboard"} -if AUTH_TYPE == 'local': +if app.config['AUTH_TYPE'] == 'local': @admin.route('/logout') @login_required def logout(): logout_user() del session['username'] return redirect(url_for('admin.login')) -elif AUTH_TYPE == 'azuread': +elif app.config['AUTH_TYPE'] == 'azuread': @admin.route('/logout') def logout(): logout_user() diff --git a/src/vr/admin/routes/register.py b/src/vr/admin/routes/register.py index 38f0b3f8..1f6f38a8 100644 --- a/src/vr/admin/routes/register.py +++ b/src/vr/admin/routes/register.py @@ -13,7 +13,6 @@ from vr.admin.helper_functions import hash_password from vr.admin.email_alerts import send_registration_email from vr.functions.initial_setup import setup_core_db_tables, generate_key_pair -from config_engine import ENV from vr.db_models.setup_2 import _init_db @@ -115,7 +114,7 @@ def register_submit(): _init_db(db=db) generate_key_pair() - setup_core_db_tables(ENV) + setup_core_db_tables(app.config['ENV']) admin_role = UserRoles.query.filter_by(name='Admin').first() ura = UserRoleAssignments(user_id=user.id, role_id=admin_role.id) db.session.add(ura) diff --git a/src/vr/admin/routes/settings.py b/src/vr/admin/routes/settings.py index fea3e3b5..532ae0d5 100644 --- a/src/vr/admin/routes/settings.py +++ b/src/vr/admin/routes/settings.py @@ -5,16 +5,8 @@ # Start of Entity-specific Imports from vr.admin import admin from vr.admin.functions import _auth_user, check_menu_tour_init -from config_engine import ENV, PROD_DB_URI, AUTH_TYPE, APP_EXT_URL, LDAP_HOST, LDAP_PORT, LDAP_BASE_DN, \ - LDAP_USER_DN, LDAP_GROUP_DN, LDAP_USER_RDN_ATTR, LDAP_USER_LOGIN_ATTR, LDAP_BIND_USER_DN, LDAP_BIND_USER_PASSWORD, \ - AZAD_CLIENT_ID, AZAD_CLIENT_SECRET, AZAD_AUTHORITY, JENKINS_USER, AZURE_KEYVAULT_NAME, INSECURE_OAUTH, \ - JENKINS_HOST, JENKINS_KEY, JENKINS_PROJECT, JENKINS_STAGING_PROJECT, JENKINS_TOKEN, SMTP_ADMIN_EMAIL, \ - SMTP_HOST, SMTP_PASSWORD, SMTP_USER, SNOW_CLIENT_ID, SNOW_CLIENT_SECRET, SNOW_INSTANCE_NAME, SNOW_PASSWORD, \ - SNOW_USERNAME, VERSION, JENKINS_ENABLED, SNOW_ENABLED -from flask_sqlalchemy import SQLAlchemy from vr.admin.models import AppConfig from vr.admin.functions import db_connection_handler -from sqlalchemy import text NAV = { @@ -44,7 +36,7 @@ def settings(): AppConfig.AZAD_CLIENT_ID: all["AZAD_CLIENT_ID"], AppConfig.AZAD_CLIENT_SECRET: all["AZAD_CLIENT_SECRET"], AppConfig.AZURE_KEYVAULT_NAME: all["AZURE_KEYVAULT_NAME"], - AppConfig.ENV: ENV, + AppConfig.ENV: app.config['ENV'], AppConfig.INSECURE_OAUTH: all["INSECURE_OAUTH"], AppConfig.JENKINS_HOST: all["JENKINS_HOST"], AppConfig.JENKINS_KEY: all["JENKINS_KEY"], @@ -71,7 +63,7 @@ def settings(): AppConfig.SNOW_INSTANCE_NAME: all["SNOW_INSTANCE_NAME"], AppConfig.SNOW_PASSWORD: all["SNOW_PASSWORD"], AppConfig.SNOW_USERNAME: all["SNOW_USERNAME"], - AppConfig.VERSION: VERSION, + AppConfig.VERSION: app.config['VERSION'], } if not app_config.settings_initialized: update_json[AppConfig.settings_initialized] = True @@ -88,7 +80,7 @@ def settings(): "AZAD_CLIENT_ID": all["AZAD_CLIENT_ID"], "AZAD_CLIENT_SECRET": all["AZAD_CLIENT_SECRET"], "AZURE_KEYVAULT_NAME": all["AZURE_KEYVAULT_NAME"], - "ENV": ENV, + "ENV": app.config['ENV'], "INSECURE_OAUTH": all["INSECURE_OAUTH"], "JENKINS_HOST": all["JENKINS_HOST"], "JENKINS_KEY": all["JENKINS_KEY"], @@ -115,7 +107,7 @@ def settings(): "SNOW_INSTANCE_NAME": all["SNOW_INSTANCE_NAME"], "SNOW_PASSWORD": all["SNOW_PASSWORD"], "SNOW_USERNAME": all["SNOW_USERNAME"], - "VERSION": VERSION, + "VERSION": app.config['VERSION'], } else: app_config = AppConfig.query.first() @@ -160,42 +152,42 @@ def settings(): } else: current_settings = { - "JENKINS_ENABLED": JENKINS_ENABLED, - "SNOW_ENABLED": SNOW_ENABLED, - "APP_EXT_URL": APP_EXT_URL, - "AUTH_TYPE": AUTH_TYPE, - "AZAD_AUTHORITY":AZAD_AUTHORITY, - "AZAD_CLIENT_ID": AZAD_CLIENT_ID, - "AZAD_CLIENT_SECRET": AZAD_CLIENT_SECRET, - "AZURE_KEYVAULT_NAME": AZURE_KEYVAULT_NAME, - "ENV": ENV, - "INSECURE_OAUTH": INSECURE_OAUTH, - "JENKINS_HOST": JENKINS_HOST, - "JENKINS_KEY": JENKINS_KEY, - "JENKINS_PROJECT": JENKINS_PROJECT, - "JENKINS_STAGING_PROJECT": JENKINS_STAGING_PROJECT, - "JENKINS_USER": JENKINS_USER, - "JENKINS_TOKEN": JENKINS_TOKEN, - "LDAP_BASE_DN": LDAP_BASE_DN, - "LDAP_BIND_USER_DN": LDAP_BIND_USER_DN, - "LDAP_BIND_USER_PASSWORD": LDAP_BIND_USER_PASSWORD, - "LDAP_GROUP_DN": LDAP_GROUP_DN, - "LDAP_HOST": LDAP_HOST, - "LDAP_PORT": LDAP_PORT, - "LDAP_USER_DN": LDAP_USER_DN, - "LDAP_USER_LOGIN_ATTR": LDAP_USER_LOGIN_ATTR, - "LDAP_USER_RDN_ATTR": LDAP_USER_RDN_ATTR, - "PROD_DB_URI": PROD_DB_URI, - "SMTP_ADMIN_EMAIL": SMTP_ADMIN_EMAIL, - "SMTP_HOST": SMTP_HOST, - "SMTP_USER": SMTP_USER, - "SMTP_PASSWORD": SMTP_PASSWORD, - "SNOW_CLIENT_ID": SNOW_CLIENT_ID, - "SNOW_CLIENT_SECRET": SNOW_CLIENT_SECRET, - "SNOW_INSTANCE_NAME": SNOW_INSTANCE_NAME, - "SNOW_USERNAME": SNOW_USERNAME, - "SNOW_PASSWORD": SNOW_PASSWORD, - "VERSION": VERSION, + "JENKINS_ENABLED": app.config['JENKINS_ENABLED'], + "SNOW_ENABLED": app.config['SNOW_ENABLED'], + "APP_EXT_URL": app.config['APP_EXT_URL'], + "AUTH_TYPE": app.config['AUTH_TYPE'], + "AZAD_AUTHORITY": app.config['AZAD_AUTHORITY'], + "AZAD_CLIENT_ID": app.config['AZAD_CLIENT_ID'], + "AZAD_CLIENT_SECRET": app.config['AZAD_CLIENT_SECRET'], + "AZURE_KEYVAULT_NAME": app.config['AZURE_KEYVAULT_NAME'], + "ENV": app.config['ENV'], + "INSECURE_OAUTH": app.config['INSECURE_OAUTH'], + "JENKINS_HOST": app.config['JENKINS_HOST'], + "JENKINS_KEY": app.config['JENKINS_KEY'], + "JENKINS_PROJECT": app.config['JENKINS_PROJECT'], + "JENKINS_STAGING_PROJECT": app.config['JENKINS_STAGING_PROJECT'], + "JENKINS_USER": app.config['JENKINS_USER'], + "JENKINS_TOKEN": app.config['JENKINS_TOKEN'], + "LDAP_BASE_DN": app.config['LDAP_BASE_DN'], + "LDAP_BIND_USER_DN": app.config['LDAP_BIND_USER_DN'], + "LDAP_BIND_USER_PASSWORD": app.config['LDAP_BIND_USER_PASSWORD'], + "LDAP_GROUP_DN": app.config['LDAP_GROUP_DN'], + "LDAP_HOST": app.config['LDAP_HOST'], + "LDAP_PORT": app.config['LDAP_PORT'], + "LDAP_USER_DN": app.config['LDAP_USER_DN'], + "LDAP_USER_LOGIN_ATTR": app.config['LDAP_USER_LOGIN_ATTR'], + "LDAP_USER_RDN_ATTR": app.config['LDAP_USER_RDN_ATTR'], + "PROD_DB_URI": app.config['PROD_DB_URI'], + "SMTP_ADMIN_EMAIL": app.config['SMTP_ADMIN_EMAIL'], + "SMTP_HOST": app.config['SMTP_HOST'], + "SMTP_USER": app.config['SMTP_USER'], + "SMTP_PASSWORD": app.config['SMTP_PASSWORD'], + "SNOW_CLIENT_ID": app.config['SNOW_CLIENT_ID'], + "SNOW_CLIENT_SECRET": app.config['SNOW_CLIENT_SECRET'], + "SNOW_INSTANCE_NAME": app.config['SNOW_INSTANCE_NAME'], + "SNOW_USERNAME": app.config['SNOW_USERNAME'], + "SNOW_PASSWORD": app.config['SNOW_PASSWORD'], + "VERSION": app.config['VERSION'], } cat_general = [ 'APP_EXT_URL', @@ -257,7 +249,7 @@ def set_env_variables(form): os.environ['AZAD_CLIENT_ID'] = form["AZAD_CLIENT_ID"] os.environ['AZAD_CLIENT_SECRET'] = form["AZAD_CLIENT_SECRET"] os.environ['AZURE_KEYVAULT_NAME'] = form["AZURE_KEYVAULT_NAME"] - os.environ['ENV'] = ENV + os.environ['ENV'] = app.config['ENV'] os.environ['INSECURE_OAUTH'] = form["INSECURE_OAUTH"] os.environ['JENKINS_ENABLED'] = form["JENKINS_ENABLED"] os.environ['JENKINS_HOST'] = form["JENKINS_HOST"] @@ -286,7 +278,43 @@ def set_env_variables(form): os.environ['SNOW_INSTANCE_NAME'] = form["SNOW_INSTANCE_NAME"] os.environ['SNOW_PASSWORD'] = form["SNOW_PASSWORD"] os.environ['SNOW_USERNAME'] = form["SNOW_USERNAME"] - os.environ['VERSION'] = VERSION + os.environ['VERSION'] = app.config['VERSION'] + app.config['APP_EXT_URL'] = form["APP_EXT_URL"] + app.config['AUTH_TYPE'] = form["AUTH_TYPE"] + app.config['AZAD_AUTHORITY'] = form["AZAD_AUTHORITY"] + app.config['AZAD_CLIENT_ID'] = form["AZAD_CLIENT_ID"] + app.config['AZAD_CLIENT_SECRET'] = form["AZAD_CLIENT_SECRET"] + app.config['AZURE_KEYVAULT_NAME'] = form["AZURE_KEYVAULT_NAME"] + app.config['ENV'] = app.config['ENV'] + app.config['INSECURE_OAUTH'] = form["INSECURE_OAUTH"] + app.config['JENKINS_ENABLED'] = form["JENKINS_ENABLED"] + app.config['JENKINS_HOST'] = form["JENKINS_HOST"] + app.config['JENKINS_KEY'] = form["JENKINS_KEY"] + app.config['JENKINS_PROJECT'] = form["JENKINS_PROJECT"] + app.config['JENKINS_STAGING_PROJECT'] = form["JENKINS_STAGING_PROJECT"] + app.config['JENKINS_TOKEN'] = form["JENKINS_TOKEN"] + app.config['JENKINS_USER'] = form["JENKINS_USER"] + app.config['LDAP_BASE_DN'] = form["LDAP_BASE_DN"] + app.config['LDAP_BIND_USER_DN'] = form["LDAP_BIND_USER_DN"] + app.config['LDAP_BIND_USER_PASSWORD'] = form["LDAP_BIND_USER_PASSWORD"] + app.config['LDAP_GROUP_DN'] = form["LDAP_GROUP_DN"] + app.config['LDAP_HOST'] = form["LDAP_HOST"] + app.config['LDAP_PORT'] = form["LDAP_PORT"] + app.config['LDAP_USER_DN'] = form["LDAP_USER_DN"] + app.config['LDAP_USER_LOGIN_ATTR'] = form["LDAP_USER_LOGIN_ATTR"] + app.config['LDAP_USER_RDN_ATTR'] = form["LDAP_USER_RDN_ATTR"] + app.config['PROD_DB_URI'] = form["PROD_DB_URI"] + app.config['SMTP_ADMIN_EMAIL'] = form["SMTP_ADMIN_EMAIL"] + app.config['SMTP_HOST'] = form["SMTP_HOST"] + app.config['SMTP_PASSWORD'] = form["SMTP_PASSWORD"] + app.config['SMTP_USER'] = form["SMTP_USER"] + app.config['SNOW_ENABLED'] = form["SNOW_ENABLED"] + app.config['SNOW_CLIENT_ID'] = form["SNOW_CLIENT_ID"] + app.config['SNOW_CLIENT_SECRET'] = form["SNOW_CLIENT_SECRET"] + app.config['SNOW_INSTANCE_NAME'] = form["SNOW_INSTANCE_NAME"] + app.config['SNOW_PASSWORD'] = form["SNOW_PASSWORD"] + app.config['SNOW_USERNAME'] = form["SNOW_USERNAME"] + app.config['VERSION'] = app.config['VERSION'] @admin.route('/dangerous/delete_all', methods=['POST']) @@ -300,7 +328,7 @@ def delete_all_data(): nav_subsubcat='', nav_curpage={"name": "Unauthorized"}) try: - if ENV == 'test': + if app.config['ENV'] == 'test': # Ensure all connections to the database are closed db.session.close() db.engine.dispose() diff --git a/src/vr/admin/routes/users.py b/src/vr/admin/routes/users.py index 5e461b33..95f12ae3 100644 --- a/src/vr/admin/routes/users.py +++ b/src/vr/admin/routes/users.py @@ -8,7 +8,6 @@ from sqlalchemy import text from flask import request, render_template, session, redirect, url_for, json from flask_login import login_required -from config_engine import AUTH_TYPE from vr.functions.table_functions import load_table, update_table from vr.admin.email_alerts import send_registration_email from vr.assets.model.businessapplications import BusinessApplications @@ -296,7 +295,7 @@ def add_new_user(): first_name=firstname, last_name=lastname, is_active=False, - auth_type=AUTH_TYPE, + auth_type=app.config['AUTH_TYPE'], otp_secret=otp_secret, user_type='system', avatar_path='/static/images/default_profile_avatar.jpg' diff --git a/src/vr/api/integrations/servicenow.py b/src/vr/api/integrations/servicenow.py index 5f76555a..ec06d99f 100644 --- a/src/vr/api/integrations/servicenow.py +++ b/src/vr/api/integrations/servicenow.py @@ -1,13 +1,12 @@ from flask import jsonify, request import requests import json +from vr import app from vr.api import api from vr.admin.oauth2 import require_oauth from authlib.integrations.flask_oauth2 import current_token from vr.admin.auth_functions import verify_api_key, get_token_auth_header from vr.functions.routing_functions import check_entity_permissions -from vr.assets.model.applicationprofiles import ApplicationProfiles, ApplicationProfilesSchema -from config_engine import SNOW_PASSWORD, SNOW_CLIENT_SECRET, SNOW_INSTANCE_NAME, SNOW_CLIENT_ID, SNOW_USERNAME ERROR_RESP = "Error: Invalid API Request" @@ -184,11 +183,11 @@ def create_new_collaboration_tools(snow_obj, app_name, app_desc): return sys_id_map # ServiceNow instance details -INSTANCE_NAME = SNOW_INSTANCE_NAME -CLIENT_ID = SNOW_CLIENT_ID -CLIENT_SECRET = SNOW_CLIENT_SECRET -USERNAME = SNOW_USERNAME -PASSWORD = SNOW_PASSWORD +INSTANCE_NAME = app.config['SNOW_INSTANCE_NAME'] +CLIENT_ID = app.config['SNOW_CLIENT_ID'] +CLIENT_SECRET = app.config['SNOW_CLIENT_SECRET'] +USERNAME = app.config['SNOW_USERNAME'] +PASSWORD = app.config['SNOW_PASSWORD'] TOKEN_URL = f'https://{INSTANCE_NAME}.service-now.com/oauth_token.do' TOKEN_DATA = { diff --git a/src/vr/api/vulns/jenkins_webhook.py b/src/vr/api/vulns/jenkins_webhook.py index 28f1824e..0b2e8b2d 100644 --- a/src/vr/api/vulns/jenkins_webhook.py +++ b/src/vr/api/vulns/jenkins_webhook.py @@ -2,10 +2,11 @@ import datetime from threading import Thread from flask import jsonify, request, json -from vr import db +from vr import db, app from vr.api import api from requests.auth import HTTPBasicAuth -from config_engine import JENKINS_USER, JENKINS_KEY, JENKINS_PROJECT, JENKINS_HOST, JENKINS_TOKEN +# from config_engine import JENKINS_USER, JENKINS_KEY, JENKINS_PROJECT, JENKINS_HOST, JENKINS_TOKEN +from config_engine import getConfigs from vr.admin.oauth2 import require_oauth from sqlalchemy import text from vr.assets.model.cicdpipelinebuilds import CICDPipelineBuilds @@ -25,6 +26,7 @@ @api.route('/api/jenkins_webhook', methods=['POST']) @require_oauth('write:vulnerabilities') def jenkins_webhook(): + getConfigs(app.config) all = request.form payload_dict = json.loads(all['payload']) ref = payload_dict['ref'] diff --git a/src/vr/api/vulns/vulnerabilities.py b/src/vr/api/vulns/vulnerabilities.py index 68360c8b..b151f5bf 100644 --- a/src/vr/api/vulns/vulnerabilities.py +++ b/src/vr/api/vulns/vulnerabilities.py @@ -16,7 +16,6 @@ from vr.admin.oauth2 import require_oauth from vr.admin.functions import db_connection_handler from authlib.integrations.flask_oauth2 import current_token -from config_engine import ENV import re @@ -295,7 +294,7 @@ def _add_new_vulns(new_vulns, engine): def _setup_duplicate_vulns(source_type, dup_vulns): sourced_dup_vulns = [] for vuln in dup_vulns: - if ENV == 'test': + if app.config['ENV'] == 'test': vuln['LastModifiedDate'] = datetime.datetime.utcnow().replace(microsecond=0) if vuln['ReleaseDate']: vuln['ReleaseDate'] = datetime.datetime.strptime(vuln['ReleaseDate'], '%Y-%m-%d %H:%M:%S') diff --git a/src/vr/db_models/setup.py b/src/vr/db_models/setup.py index b36fdc22..cb37b344 100644 --- a/src/vr/db_models/setup.py +++ b/src/vr/db_models/setup.py @@ -1,11 +1,6 @@ from datetime import datetime from sqlalchemy.types import TEXT, DECIMAL from flask import jsonify -from config_engine import ENV -if ENV == 'test': - from sqlalchemy.dialects.sqlite import TEXT as LONGTEXT -else: - from sqlalchemy.dialects.mysql import LONGTEXT from flask_sqlalchemy import SQLAlchemy from sqlalchemy.dialects import mysql from flask_login import UserMixin @@ -176,9 +171,9 @@ class TmControls(db.Model): __tablename__ = 'TmControls' ID = db.Column(db.Integer, primary_key=True) AddDate = db.Column(db.DateTime, index=True, default=datetime.utcnow, nullable=False) - Control = db.Column(LONGTEXT) + Control = db.Column(db.String(20000)) Type = db.Column(db.String(8)) - Description = db.Column(LONGTEXT) + Description = db.Column(db.String(20000)) Lambda = db.Column(db.String(1)) Process = db.Column(db.String(1)) Server = db.Column(db.String(1)) diff --git a/src/vr/db_models/setup_2.py b/src/vr/db_models/setup_2.py index d47ba210..0d98c122 100644 --- a/src/vr/db_models/setup_2.py +++ b/src/vr/db_models/setup_2.py @@ -2,8 +2,8 @@ from sqlalchemy.types import TEXT, DECIMAL from sqlalchemy import MetaData from vr.admin.functions import db_connection_handler -from config_engine import ENV -if ENV == 'test': +from vr import app +if app.config['ENV'] == 'test': from sqlalchemy.dialects.sqlite import TEXT as LONGTEXT else: from sqlalchemy.dialects.mysql import LONGTEXT diff --git a/src/vr/orchestration/web/pipeline_jobs.py b/src/vr/orchestration/web/pipeline_jobs.py index e9fcc7ee..2ef5390b 100644 --- a/src/vr/orchestration/web/pipeline_jobs.py +++ b/src/vr/orchestration/web/pipeline_jobs.py @@ -11,7 +11,6 @@ from vr.orchestration.model.cicdpipelines import CICDPipelines, CICDPipelinesSchema from vr.orchestration.model.pipelinejobs import PipelineJobs, PipelineJobsSchema from vr.orchestration.web.pipeline_stage_data import OPTS -from config_engine import JENKINS_USER, JENKINS_KEY, JENKINS_STAGING_PROJECT, JENKINS_HOST, JENKINS_TOKEN NAV = { @@ -248,7 +247,7 @@ def validate_cicd_pipeline_stage(appid): "Content-Type": "application/x-www-form-urlencoded" } data = { - 'token': JENKINS_TOKEN, + 'token': app.config['JENKINS_TOKEN'], 'GIT_URL': git_url, 'GIT_BRANCH': git_branch, 'APP_NAME': app_name, @@ -261,8 +260,8 @@ def validate_cicd_pipeline_stage(appid): 'TARGET_URL': target_url } - url = f'{JENKINS_HOST}/job/{JENKINS_STAGING_PROJECT}/buildWithParameters' - resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(JENKINS_USER, JENKINS_KEY)) + url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_STAGING_PROJECT']}/buildWithParameters" + resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) return str(200) diff --git a/src/vr/templates/admin/settings.html b/src/vr/templates/admin/settings.html index a7564e1a..f5da3318 100644 --- a/src/vr/templates/admin/settings.html +++ b/src/vr/templates/admin/settings.html @@ -134,7 +134,7 @@

General Settings

{% elif key == "PROD_DB_URI" %} -
+
{% elif key == "ENV" or key == "VERSION" %} {% else %} @@ -176,7 +176,7 @@

SMTP Settings

{% if key == 'SMTP_PASSWORD' %} -
+
{% else %} {% endif %} @@ -199,10 +199,10 @@

Jenkins Settings

{% elif key == 'JENKINS_KEY' %} -
+
{% elif key == 'JENKINS_TOKEN' %} -
+
{% else %} @@ -229,10 +229,10 @@

ServiceNOW Settings

{% elif key == 'SNOW_CLIENT_SECRET' %} -
+
{% elif key == 'SNOW_PASSWORD' %} -
+
{% else %} diff --git a/src/vr/vulns/web/findings.py b/src/vr/vulns/web/findings.py index 8c9938c8..06d44322 100644 --- a/src/vr/vulns/web/findings.py +++ b/src/vr/vulns/web/findings.py @@ -25,7 +25,6 @@ import base64 from io import StringIO from flask import Response -from config_engine import ENV from vr.functions.ml_functions import predict_vuln_validity from vr.vulns.model.cvssbasescoresv3 import CVSSBaseScoresV3 from vr.vulns.model.cvssbasescoresv3extensions import CVSSBaseScoresV3Extensions @@ -42,7 +41,7 @@ UNAUTH_STATUS = "403.html" SERVER_ERR_STATUS = "500.html" VULN_STATUS_IS_NOT_CLOSED = "Vulnerabilities.Status NOT LIKE 'Closed-%' AND Vulnerabilities.Status NOT LIKE 'Open-RiskAccepted-%'" -test = ENV +test = app.config['ENV'] if test == 'test': ISO_FORMAT = "%Y-%m-%dT%H:%M:%S.%f" else: diff --git a/src/vr/vulns/web/testing.py b/src/vr/vulns/web/testing.py index 32e604b8..c69f7122 100644 --- a/src/vr/vulns/web/testing.py +++ b/src/vr/vulns/web/testing.py @@ -11,8 +11,8 @@ from vr.vulns.model.vulnerabilityscans import VulnerabilityScans, VulnerabilityScansSchema from vr.functions.table_functions import load_table, update_table from requests.auth import HTTPBasicAuth -from config_engine import JENKINS_USER, JENKINS_KEY, JENKINS_PROJECT, JENKINS_HOST, JENKINS_TOKEN from vr.assets.model.applicationprofiles import ApplicationProfiles, ApplicationProfilesSchema +from vr import app NAV = { @@ -115,14 +115,14 @@ def on_demand_testing(): "Content-Type": "application/x-www-form-urlencoded" } data = { - 'token': JENKINS_TOKEN, + 'token': app.config['JENKINS_TOKEN'], 'GIT_URL': git_url, 'TESTS': tests_to_run.upper(), 'GIT_BRANCH': git_branch, 'APP_NAME': app_name } - url = f'{JENKINS_HOST}/job/{JENKINS_PROJECT}/buildWithParameters' - resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(JENKINS_USER, JENKINS_KEY)) + url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" + resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) return redirect(request.referrer) From d0f7120c34e3a58c60e82404516a9b7282bbf59e Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 07:48:21 -0700 Subject: [PATCH 075/197] Update run.py --- src/run.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/run.py b/src/run.py index 7f0f15c7..b67be678 100644 --- a/src/run.py +++ b/src/run.py @@ -4,10 +4,9 @@ import datetime import os from vr.admin.oauth2 import config_oauth -from config_engine import ENV, INSECURE_OAUTH -if ENV == 'test' or INSECURE_OAUTH: +if app.config['ENV'] == 'test' or app.config['INSECURE_OAUTH']: os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1' else: os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '0' From e50317f5019c213fb9c44a9630aa0cc38be4b08b Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 07:54:52 -0700 Subject: [PATCH 076/197] Feature/fix syntax error (#517) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py --- src/config_engine.py | 430 +++++++++++----------- src/run.py | 3 +- src/vr/__init__.py | 102 +++-- src/vr/admin/auth_functions.py | 4 +- src/vr/admin/email_alerts.py | 8 +- src/vr/admin/models.py | 9 +- src/vr/admin/routes/forgotpw.py | 3 +- src/vr/admin/routes/forgotun.py | 3 +- src/vr/admin/routes/login.py | 15 +- src/vr/admin/routes/logout.py | 6 +- src/vr/admin/routes/register.py | 3 +- src/vr/admin/routes/settings.py | 130 ++++--- src/vr/admin/routes/users.py | 3 +- src/vr/api/integrations/servicenow.py | 13 +- src/vr/api/vulns/jenkins_webhook.py | 6 +- src/vr/api/vulns/vulnerabilities.py | 3 +- src/vr/db_models/setup.py | 9 +- src/vr/db_models/setup_2.py | 4 +- src/vr/orchestration/web/pipeline_jobs.py | 7 +- src/vr/templates/admin/settings.html | 12 +- src/vr/vulns/web/findings.py | 3 +- src/vr/vulns/web/testing.py | 8 +- 22 files changed, 421 insertions(+), 363 deletions(-) diff --git a/src/config_engine.py b/src/config_engine.py index 07400d06..7ee859ad 100644 --- a/src/config_engine.py +++ b/src/config_engine.py @@ -14,98 +14,229 @@ from settings import SET_SNOW_INSTANCE_NAME, SET_SNOW_CLIENT_ID, SET_SNOW_CLIENT_SECRET, SET_SNOW_USERNAME, SET_SNOW_PASSWORD, SET_SNOW_CLIENT_SECRET_REF, SET_SNOW_PASSWORD_REF -VERSION = '0.1.0-beta' - -if os.getenv('AZURE_KEYVAULT_NAME'): - AZURE_KEYVAULT_NAME = os.getenv('AZURE_KEYVAULT_NAME') -else: - AZURE_KEYVAULT_NAME = SET_AZURE_KEYVAULT_NAME - -if os.getenv('AUTH_TYPE'): - AUTH_TYPE = os.getenv('AUTH_TYPE') -else: - AUTH_TYPE = SET_AUTH_TYPE - -if os.getenv('INSECURE_OAUTH'): - INSECURE_OAUTH = os.getenv('INSECURE_OAUTH') -else: - INSECURE_OAUTH = SET_INSECURE_OAUTH - -if INSECURE_OAUTH: - os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1' - -if os.getenv('APP_EXT_URL'): - APP_EXT_URL = os.getenv('APP_EXT_URL') -else: - APP_EXT_URL = SET_APP_EXT_URL - -if os.getenv('SMTP_HOST'): - SMTP_HOST = os.getenv('SMTP_HOST') -else: - SMTP_HOST = SET_SMTP_HOST - -if os.getenv('SMTP_USER'): - SMTP_USER = os.getenv('SMTP_USER') -else: - SMTP_USER = SET_SMTP_USER - -if os.getenv('SMTP_ADMIN_EMAIL'): - SMTP_ADMIN_EMAIL = os.getenv('SMTP_ADMIN_EMAIL') -else: - SMTP_ADMIN_EMAIL = SET_SMTP_ADMIN_EMAIL - -if os.getenv('LDAP_HOST'): - LDAP_HOST = os.getenv('LDAP_HOST') -else: - LDAP_HOST = SET_LDAP_HOST - -if os.getenv('LDAP_PORT'): - LDAP_PORT = os.getenv('LDAP_PORT') -else: - LDAP_PORT = SET_LDAP_PORT - -if os.getenv('LDAP_BASE_DN'): - LDAP_BASE_DN = os.getenv('LDAP_BASE_DN') -else: - LDAP_BASE_DN = SET_LDAP_BASE_DN - -if os.getenv('LDAP_USER_DN'): - LDAP_USER_DN = os.getenv('LDAP_USER_DN') -else: - LDAP_USER_DN = SET_LDAP_USER_DN - -if os.getenv('LDAP_GROUP_DN'): - LDAP_GROUP_DN = os.getenv('LDAP_GROUP_DN') -else: - LDAP_GROUP_DN = SET_LDAP_GROUP_DN - -if os.getenv('LDAP_USER_RDN_ATTR'): - LDAP_USER_RDN_ATTR = os.getenv('LDAP_USER_RDN_ATTR') -else: - LDAP_USER_RDN_ATTR = SET_LDAP_USER_RDN_ATTR - -if os.getenv('LDAP_USER_LOGIN_ATTR'): - LDAP_USER_LOGIN_ATTR = os.getenv('LDAP_USER_LOGIN_ATTR') -else: - LDAP_USER_LOGIN_ATTR = SET_LDAP_USER_LOGIN_ATTR - -if os.getenv('LDAP_BIND_USER_DN'): - LDAP_BIND_USER_DN = os.getenv('LDAP_BIND_USER_DN') -else: - LDAP_BIND_USER_DN = SET_LDAP_BIND_USER_DN - -if os.getenv('LDAP_BIND_USER_PASSWORD'): - LDAP_BIND_USER_PASSWORD = os.getenv('LDAP_BIND_USER_PASSWORD') -else: - LDAP_BIND_USER_PASSWORD = SET_LDAP_BIND_USER_PASSWORD +def getConfigs(config): + config['TEST_SETTING'] = 'set' + + config['VERSION'] = '0.1.0-beta' + + if os.getenv('AZURE_KEYVAULT_NAME'): + config['AZURE_KEYVAULT_NAME'] = os.getenv('AZURE_KEYVAULT_NAME') + else: + config['AZURE_KEYVAULT_NAME'] = SET_AZURE_KEYVAULT_NAME + + if os.getenv('AUTH_TYPE'): + config['AUTH_TYPE'] = os.getenv('AUTH_TYPE') + else: + config['AUTH_TYPE'] = SET_AUTH_TYPE + + if os.getenv('INSECURE_OAUTH'): + config['INSECURE_OAUTH'] = os.getenv('INSECURE_OAUTH') + else: + config['INSECURE_OAUTH'] = SET_INSECURE_OAUTH + + if config['INSECURE_OAUTH']: + os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1' + + if os.getenv('APP_EXT_URL'): + config['APP_EXT_URL'] = os.getenv('APP_EXT_URL') + else: + config['APP_EXT_URL'] = SET_APP_EXT_URL + + if os.getenv('SMTP_HOST'): + config['SMTP_HOST'] = os.getenv('SMTP_HOST') + else: + config['SMTP_HOST'] = SET_SMTP_HOST + + if os.getenv('SMTP_USER'): + config['SMTP_USER'] = os.getenv('SMTP_USER') + else: + config['SMTP_USER'] = SET_SMTP_USER + + if os.getenv('SMTP_ADMIN_EMAIL'): + config['SMTP_ADMIN_EMAIL'] = os.getenv('SMTP_ADMIN_EMAIL') + else: + config['SMTP_ADMIN_EMAIL'] = SET_SMTP_ADMIN_EMAIL + + if os.getenv('LDAP_HOST'): + config['LDAP_HOST'] = os.getenv('LDAP_HOST') + else: + config['LDAP_HOST'] = SET_LDAP_HOST + + if os.getenv('LDAP_PORT'): + config['LDAP_PORT'] = os.getenv('LDAP_PORT') + else: + config['LDAP_PORT'] = SET_LDAP_PORT + + if os.getenv('LDAP_BASE_DN'): + config['LDAP_BASE_DN'] = os.getenv('LDAP_BASE_DN') + else: + config['LDAP_BASE_DN'] = SET_LDAP_BASE_DN + + if os.getenv('LDAP_USER_DN'): + config['LDAP_USER_DN'] = os.getenv('LDAP_USER_DN') + else: + config['LDAP_USER_DN'] = SET_LDAP_USER_DN + + if os.getenv('LDAP_GROUP_DN'): + config['LDAP_GROUP_DN'] = os.getenv('LDAP_GROUP_DN') + else: + config['LDAP_GROUP_DN'] = SET_LDAP_GROUP_DN + + if os.getenv('LDAP_USER_RDN_ATTR'): + config['LDAP_USER_RDN_ATTR'] = os.getenv('LDAP_USER_RDN_ATTR') + else: + config['LDAP_USER_RDN_ATTR'] = SET_LDAP_USER_RDN_ATTR + + if os.getenv('LDAP_USER_LOGIN_ATTR'): + config['LDAP_USER_LOGIN_ATTR'] = os.getenv('LDAP_USER_LOGIN_ATTR') + else: + config['LDAP_USER_LOGIN_ATTR'] = SET_LDAP_USER_LOGIN_ATTR + + if os.getenv('LDAP_BIND_USER_DN'): + config['LDAP_BIND_USER_DN'] = os.getenv('LDAP_BIND_USER_DN') + else: + config['LDAP_BIND_USER_DN'] = SET_LDAP_BIND_USER_DN + + if os.getenv('LDAP_BIND_USER_PASSWORD'): + config['LDAP_BIND_USER_PASSWORD'] = os.getenv('LDAP_BIND_USER_PASSWORD') + else: + config['LDAP_BIND_USER_PASSWORD'] = SET_LDAP_BIND_USER_PASSWORD + + ## CORE Config Variables ## + if os.getenv('ENV'): + config['ENV'] = os.getenv('ENV') + else: + config['ENV'] = SET_ENV + + if config['ENV'] == 'prod': + if os.getenv('PROD_DB_URI_REF'): + config['PROD_DB_URI'] = KeyVaultManager(config).get_secret(os.getenv('PROD_DB_URI_REF')) + else: + config['PROD_DB_URI'] = KeyVaultManager(config).get_secret(SET_PROD_DB_URI_REF) + else: + config['PROD_DB_URI'] = SET_PROD_DB_URI + + if config['AUTH_TYPE'] == 'azuread': + if os.getenv('AZAD_CLIENT_ID'): + config['AZAD_CLIENT_ID'] = os.getenv('AZAD_CLIENT_ID') + else: + config['AZAD_CLIENT_ID'] = SET_AZAD_CLIENT_ID + if os.getenv('AZAD_CLIENT_SECRET'): + config['AZAD_CLIENT_SECRET'] = KeyVaultManager(config).get_secret(os.getenv('AZAD_CLIENT_SECRET')) + else: + config['AZAD_CLIENT_SECRET'] = KeyVaultManager(config).get_secret(SET_AZAD_CLIENT_SECRET) + if os.getenv('AZAD_AUTHORITY'): + config['AZAD_AUTHORITY'] = os.getenv('AZAD_AUTHORITY') + else: + config['AZAD_AUTHORITY'] = SET_AZAD_AUTHORITY + else: + config['AZAD_CLIENT_ID'] = "" + config['AZAD_CLIENT_SECRET'] = "" + config['AZAD_AUTHORITY'] = "" + + ## Email Variables ## + if config['ENV'] == 'prod': + if os.getenv('SMTP_PW_REF'): + config['SMTP_PASSWORD'] = KeyVaultManager(config).get_secret(os.getenv('SMTP_PW_REF')) + else: + config['SMTP_PASSWORD'] = KeyVaultManager(config).get_secret(SET_SMTP_PW_REF) + else: + config['SMTP_PASSWORD'] = SET_SMTP_PW + + ## + ## GitHub to Jenkins Webhook ## + if os.getenv('JENKINS_ENABLED'): + config['JENKINS_ENABLED'] = os.getenv('JENKINS_ENABLED') + else: + config['JENKINS_ENABLED'] = SET_JENKINS_ENABLED + if config['JENKINS_ENABLED'] == 'yes': + if config['ENV'] == 'prod': + if os.getenv('JENKINS_USER'): + config['JENKINS_USER'] = KeyVaultManager(config).get_secret(os.getenv('JENKINS_USER')) + else: + config['JENKINS_USER'] = KeyVaultManager(config).get_secret(SET_JENKINS_USER_REF) + if os.getenv('JENKINS_KEY'): + config['JENKINS_KEY'] = KeyVaultManager(config).get_secret(os.getenv('JENKINS_KEY')) + else: + config['JENKINS_KEY'] = KeyVaultManager(config).get_secret(SET_JENKINS_KEY_REF) + if os.getenv('JENKINS_TOKEN'): + config['JENKINS_TOKEN'] = KeyVaultManager(config).get_secret(os.getenv('JENKINS_TOKEN')) + else: + config['JENKINS_TOKEN'] = KeyVaultManager(config).get_secret(SET_JENKINS_TOKEN_REF) + else: + config['JENKINS_USER'] = SET_JENKINS_USER + config['JENKINS_KEY'] = SET_JENKINS_KEY + config['JENKINS_TOKEN'] = SET_JENKINS_TOKEN + + if os.getenv('JENKINS_PROJECT'): + config['JENKINS_PROJECT'] = os.getenv('JENKINS_PROJECT') + else: + config['JENKINS_PROJECT'] = SET_JENKINS_PROJECT + + if os.getenv('JENKINS_HOST'): + config['JENKINS_HOST'] = os.getenv('JENKINS_HOST') + else: + config['JENKINS_HOST'] = SET_JENKINS_HOST + + if os.getenv('JENKINS_STAGING_PROJECT'): + config['JENKINS_STAGING_PROJECT'] = os.getenv('JENKINS_STAGING_PROJECT') + else: + config['JENKINS_STAGING_PROJECT'] = SET_JENKINS_STAGING_PROJECT + else: + config['JENKINS_USER'] = "" + config['JENKINS_KEY'] = "" + config['JENKINS_TOKEN'] = "" + config['JENKINS_PROJECT'] = "" + config['JENKINS_HOST'] = "" + config['JENKINS_STAGING_PROJECT'] = "" + + ## ServiceNOW Integration + if os.getenv('SNOW_ENABLED'): + config['SNOW_ENABLED'] = os.getenv('SNOW_ENABLED') + else: + config['SNOW_ENABLED'] = SET_SNOW_ENABLED + if config['SNOW_ENABLED'] == 'yes': + if config['ENV'] == 'prod': + if os.getenv('SNOW_PASSWORD'): + config['SNOW_PASSWORD'] = KeyVaultManager(config).get_secret(os.getenv('SNOW_PASSWORD')) + else: + config['SNOW_PASSWORD'] = KeyVaultManager(config).get_secret(SET_SNOW_PASSWORD_REF) + if os.getenv('SNOW_CLIENT_SECRET'): + config['SNOW_CLIENT_SECRET'] = KeyVaultManager(config).get_secret(os.getenv('SNOW_CLIENT_SECRET')) + else: + config['SNOW_CLIENT_SECRET'] = KeyVaultManager(config).get_secret(SET_SNOW_CLIENT_SECRET_REF) + if os.getenv('SNOW_INSTANCE_NAME'): + config['SNOW_INSTANCE_NAME'] = os.getenv('SNOW_INSTANCE_NAME') + else: + config['SNOW_INSTANCE_NAME'] = SET_SNOW_INSTANCE_NAME + if os.getenv('SNOW_CLIENT_ID'): + config['SNOW_CLIENT_ID'] = os.getenv('SNOW_CLIENT_ID') + else: + config['SNOW_CLIENT_ID'] = SET_SNOW_CLIENT_ID + if os.getenv('SNOW_USERNAME'): + config['SNOW_USERNAME'] = os.getenv('SNOW_USERNAME') + else: + config['SNOW_USERNAME'] = SET_SNOW_USERNAME + else: + config['SNOW_PASSWORD'] = SET_SNOW_PASSWORD + config['SNOW_CLIENT_SECRET'] = SET_SNOW_CLIENT_SECRET + config['SNOW_INSTANCE_NAME'] = SET_SNOW_INSTANCE_NAME + config['SNOW_CLIENT_ID'] = SET_SNOW_CLIENT_ID + config['SNOW_USERNAME'] = SET_SNOW_USERNAME + else: + config['SNOW_PASSWORD'] = "" + config['SNOW_CLIENT_SECRET'] = "" + config['SNOW_INSTANCE_NAME'] = "" + config['SNOW_CLIENT_ID'] = "" + config['SNOW_USERNAME'] = "" class KeyVaultManager(object): - def __init__(self): + def __init__(self, config=None): if os.getenv('AZURE_KEYVAULT_NAME'): key_vault_uri = f"https://{os.getenv('AZURE_KEYVAULT_NAME')}.vault.azure.net" else: - key_vault_uri = f"https://{AZURE_KEYVAULT_NAME}.vault.azure.net" + key_vault_uri = f"https://{config['AZURE_KEYVAULT_NAME']}.vault.azure.net" if os.getenv('AZURE_AUTH_METHOD'): if os.getenv('AZURE_AUTH_METHOD') == 'env': self.credential = EnvironmentCredential( @@ -162,130 +293,3 @@ def delete_cert(self, secret_name): return deleted_secret -## CORE Config Variables ## -if os.getenv('ENV'): - ENV = os.getenv('ENV') -else: - ENV = SET_ENV - -if ENV == 'prod': - if os.getenv('PROD_DB_URI_REF'): - PROD_DB_URI = KeyVaultManager().get_secret(os.getenv('PROD_DB_URI_REF')) - else: - PROD_DB_URI = KeyVaultManager().get_secret(SET_PROD_DB_URI_REF) -else: - PROD_DB_URI = SET_PROD_DB_URI - -if AUTH_TYPE == 'azuread': - if os.getenv('AZAD_CLIENT_ID'): - AZAD_CLIENT_ID = os.getenv('AZAD_CLIENT_ID') - else: - AZAD_CLIENT_ID = SET_AZAD_CLIENT_ID - if os.getenv('AZAD_CLIENT_SECRET'): - AZAD_CLIENT_SECRET = KeyVaultManager().get_secret(os.getenv('AZAD_CLIENT_SECRET')) - else: - AZAD_CLIENT_SECRET = KeyVaultManager().get_secret(SET_AZAD_CLIENT_SECRET) - if os.getenv('AZAD_AUTHORITY'): - AZAD_AUTHORITY = os.getenv('AZAD_AUTHORITY') - else: - AZAD_AUTHORITY = SET_AZAD_AUTHORITY -else: - AZAD_CLIENT_ID = "" - AZAD_CLIENT_SECRET = "" - AZAD_AUTHORITY = "" - -## Email Variables ## -if ENV == 'prod': - if os.getenv('SMTP_PW_REF'): - SMTP_PASSWORD = KeyVaultManager().get_secret(os.getenv('SMTP_PW_REF')) - else: - SMTP_PASSWORD = KeyVaultManager().get_secret(SET_SMTP_PW_REF) -else: - SMTP_PASSWORD = SET_SMTP_PW - -## -## GitHub to Jenkins Webhook ## -if os.getenv('JENKINS_ENABLED'): - JENKINS_ENABLED = os.getenv('JENKINS_ENABLED') -else: - JENKINS_ENABLED = SET_JENKINS_ENABLED -if JENKINS_ENABLED == 'yes': - if ENV == 'prod': - if os.getenv('JENKINS_USER'): - JENKINS_USER = KeyVaultManager().get_secret(os.getenv('JENKINS_USER')) - else: - JENKINS_USER = KeyVaultManager().get_secret(SET_JENKINS_USER_REF) - if os.getenv('JENKINS_KEY'): - JENKINS_KEY = KeyVaultManager().get_secret(os.getenv('JENKINS_KEY')) - else: - JENKINS_KEY = KeyVaultManager().get_secret(SET_JENKINS_KEY_REF) - if os.getenv('JENKINS_TOKEN'): - JENKINS_TOKEN = KeyVaultManager().get_secret(os.getenv('JENKINS_TOKEN')) - else: - JENKINS_TOKEN = KeyVaultManager().get_secret(SET_JENKINS_TOKEN_REF) - else: - JENKINS_USER = SET_JENKINS_USER - JENKINS_KEY = SET_JENKINS_KEY - JENKINS_TOKEN = SET_JENKINS_TOKEN - - if os.getenv('JENKINS_PROJECT'): - JENKINS_PROJECT = os.getenv('JENKINS_PROJECT') - else: - JENKINS_PROJECT = SET_JENKINS_PROJECT - - if os.getenv('JENKINS_HOST'): - JENKINS_HOST = os.getenv('JENKINS_HOST') - else: - JENKINS_HOST = SET_JENKINS_HOST - - if os.getenv('JENKINS_STAGING_PROJECT'): - JENKINS_STAGING_PROJECT = os.getenv('JENKINS_STAGING_PROJECT') - else: - JENKINS_STAGING_PROJECT = SET_JENKINS_STAGING_PROJECT -else: - JENKINS_USER = "" - JENKINS_KEY = "" - JENKINS_TOKEN = "" - JENKINS_PROJECT = "" - JENKINS_HOST = "" - JENKINS_STAGING_PROJECT = "" - -## ServiceNOW Integration -if os.getenv('SNOW_ENABLED'): - SNOW_ENABLED = os.getenv('SNOW_ENABLED') -else: - SNOW_ENABLED = SET_SNOW_ENABLED -if SNOW_ENABLED == 'yes': - if ENV == 'prod': - if os.getenv('SNOW_PASSWORD'): - SNOW_PASSWORD = KeyVaultManager().get_secret(os.getenv('SNOW_PASSWORD')) - else: - SNOW_PASSWORD = KeyVaultManager().get_secret(SET_SNOW_PASSWORD_REF) - if os.getenv('SNOW_CLIENT_SECRET'): - SNOW_CLIENT_SECRET = KeyVaultManager().get_secret(os.getenv('SNOW_CLIENT_SECRET')) - else: - SNOW_CLIENT_SECRET = KeyVaultManager().get_secret(SET_SNOW_CLIENT_SECRET_REF) - if os.getenv('SNOW_INSTANCE_NAME'): - SNOW_INSTANCE_NAME = os.getenv('SNOW_INSTANCE_NAME') - else: - SNOW_INSTANCE_NAME = SET_SNOW_INSTANCE_NAME - if os.getenv('SNOW_CLIENT_ID'): - SNOW_CLIENT_ID = os.getenv('SNOW_CLIENT_ID') - else: - SNOW_CLIENT_ID = SET_SNOW_CLIENT_ID - if os.getenv('SNOW_USERNAME'): - SNOW_USERNAME = os.getenv('SNOW_USERNAME') - else: - SNOW_USERNAME = SET_SNOW_USERNAME - else: - SNOW_PASSWORD = SET_SNOW_PASSWORD - SNOW_CLIENT_SECRET = SET_SNOW_CLIENT_SECRET - SNOW_INSTANCE_NAME = SET_SNOW_INSTANCE_NAME - SNOW_CLIENT_ID = SET_SNOW_CLIENT_ID - SNOW_USERNAME = SET_SNOW_USERNAME -else: - SNOW_PASSWORD = "" - SNOW_CLIENT_SECRET = "" - SNOW_INSTANCE_NAME = "" - SNOW_CLIENT_ID = "" - SNOW_USERNAME = "" diff --git a/src/run.py b/src/run.py index 7f0f15c7..b67be678 100644 --- a/src/run.py +++ b/src/run.py @@ -4,10 +4,9 @@ import datetime import os from vr.admin.oauth2 import config_oauth -from config_engine import ENV, INSECURE_OAUTH -if ENV == 'test' or INSECURE_OAUTH: +if app.config['ENV'] == 'test' or app.config['INSECURE_OAUTH']: os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1' else: os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '0' diff --git a/src/vr/__init__.py b/src/vr/__init__.py index 42a86ea1..2f3ccf73 100644 --- a/src/vr/__init__.py +++ b/src/vr/__init__.py @@ -1,8 +1,6 @@ import datetime import requests -from config_engine import ENV, PROD_DB_URI, AUTH_TYPE, APP_EXT_URL, LDAP_HOST, LDAP_PORT, LDAP_BASE_DN, \ - LDAP_USER_DN, LDAP_GROUP_DN, LDAP_USER_RDN_ATTR, LDAP_USER_LOGIN_ATTR, LDAP_BIND_USER_DN, LDAP_BIND_USER_PASSWORD, \ - AZAD_CLIENT_ID, AZAD_CLIENT_SECRET, AZAD_AUTHORITY, JENKINS_USER, JENKINS_ENABLED +from config_engine import getConfigs from flask import Flask from flask_bootstrap import Bootstrap from flask_login import LoginManager @@ -11,8 +9,7 @@ from flask_wtf.csrf import CSRFProtect from flaskext.markdown import Markdown from vr.db_models.setup import _init_db -if AUTH_TYPE == 'ldap': - from flask_ldap3_login import LDAP3LoginManager + import base64 import logging import sys @@ -31,48 +28,41 @@ from requests.auth import HTTPBasicAuth from vr.db_models.updates import createNewTables -if AUTH_TYPE == 'azuread': + +app = Flask(__name__) + +getConfigs(app.config) + +if app.config['AUTH_TYPE'] == 'azuread': from flask_session import Session import msal from flask import session, url_for +if app.config['AUTH_TYPE'] == 'ldap': + from flask_ldap3_login import LDAP3LoginManager -app = Flask(__name__) moment = Moment(app) Markdown(app) csrf = CSRFProtect(app) -app.config['APP_EXT_URL'] = APP_EXT_URL - -app.config['RUNTIME_ENV'] = ENV +app.config['RUNTIME_ENV'] = app.config['ENV'] if app.config['RUNTIME_ENV'] == 'test': DB_URI = 'sqlite:///database.db' import sqlite3 else: - DB_URI = PROD_DB_URI + DB_URI = app.config['PROD_DB_URI'] import mysql.connector app.config['SQLALCHEMY_DATABASE_URI'] = DB_URI app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False -if AUTH_TYPE == 'ldap': - # LDAP Configuration - app.config['LDAP_HOST'] = LDAP_HOST - app.config['LDAP_PORT'] = LDAP_PORT - app.config['LDAP_BASE_DN'] = LDAP_BASE_DN - app.config['LDAP_USER_DN'] = LDAP_USER_DN - app.config['LDAP_GROUP_DN'] = LDAP_GROUP_DN - app.config['LDAP_USER_RDN_ATTR'] = LDAP_USER_RDN_ATTR - app.config['LDAP_USER_LOGIN_ATTR'] = LDAP_USER_LOGIN_ATTR - app.config['LDAP_BIND_USER_DN'] = LDAP_BIND_USER_DN - app.config['LDAP_BIND_USER_PASSWORD'] = LDAP_BIND_USER_PASSWORD - +if app.config['AUTH_TYPE'] == 'ldap': # Flask-LDAP3-Login Manager ldap_manager = LDAP3LoginManager(app) -elif AUTH_TYPE == 'azuread': - app.config['CLIENT_ID'] = AZAD_CLIENT_ID - app.config['CLIENT_SECRET'] = AZAD_CLIENT_SECRET - app.config['AUTHORITY'] = AZAD_AUTHORITY +elif app.config['AUTH_TYPE'] == 'azuread': + app.config['CLIENT_ID'] = app.config['AZAD_CLIENT_ID'] + app.config['CLIENT_SECRET'] = app.config['AZAD_CLIENT_SECRET'] + app.config['AUTHORITY'] = app.config['AZAD_AUTHORITY'] app.config['REDIRECT_PATH'] = "/getAToken" app.config['ENDPOINT'] = 'https://graph.microsoft.com/v1.0/me/memberOf' app.config['SCOPE'] = ["User.ReadBasic.All", "Group.Read.All", "Application.Read.All"] @@ -151,7 +141,7 @@ def _get_token_from_cache(scope=None): app.register_blueprint(api) bootstrap = Bootstrap(app) -if AUTH_TYPE == 'local' or AUTH_TYPE == 'azuread': +if app.config['AUTH_TYPE'] == 'local' or app.config['AUTH_TYPE'] == 'azuread': login_manager.init_app(app) login_manager.login_view = 'admin.login' @@ -162,9 +152,10 @@ def _get_token_from_cache(scope=None): app.logger.addHandler(stdout_handler) + @app.template_filter('format_datetime') def format_datetime(value): - if ENV == 'test': + if app.config['ENV'] == 'test': try: formatted = datetime.datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f") except: @@ -185,6 +176,8 @@ def base64encode(value): createNewTables(app) ## Cronjob-like tasks section ## + + def train_model_every_six_hours(): scheduler = BackgroundScheduler() scheduler.add_job(train_model, 'interval', hours=6) @@ -220,6 +213,53 @@ def connect_to_db(): cur = db.cursor() return cur, db +def getPersistentConfig(): + try: + cur, db = connect_to_db() + sql = 'SELECT * FROM AppConfig WHERE 1=1' + cur.execute(sql) + row = cur.fetchone() + if row[2]: + app.config['APP_EXT_URL'] = row[3] + app.config['AUTH_TYPE'] = row[4] + app.config['AZAD_AUTHORITY'] = row[5] + app.config['AZAD_CLIENT_ID'] = row[6] + app.config['AZAD_CLIENT_SECRET'] = row[7] + app.config['AZURE_KEYVAULT_NAME'] = row[8] + app.config['ENV'] = row[9] + app.config['INSECURE_OAUTH'] = row[10] + app.config['JENKINS_ENABLED'] = row[37] + app.config['JENKINS_HOST'] = row[11] + app.config['JENKINS_KEY'] = row[12] + app.config['JENKINS_PROJECT'] = row[13] + app.config['JENKINS_STAGING_PROJECT'] = row[14] + app.config['JENKINS_TOKEN'] = row[15] + app.config['JENKINS_USER'] = row[16] + app.config['LDAP_BASE_DN'] = row[17] + app.config['LDAP_BIND_USER_DN'] = row[18] + app.config['LDAP_BIND_USER_PASSWORD'] = row[19] + app.config['LDAP_GROUP_DN'] = row[20] + app.config['LDAP_HOST'] = row[21] + app.config['LDAP_PORT'] = row[22] + app.config['LDAP_USER_DN'] = row[23] + app.config['LDAP_USER_LOGIN_ATTR'] = row[24] + app.config['LDAP_USER_RDN_ATTR'] = row[25] + app.config['PROD_DB_URI'] = row[26] + app.config['SMTP_ADMIN_EMAIL'] = row[27] + app.config['SMTP_HOST'] = row[28] + app.config['SMTP_PASSWORD'] = row[29] + app.config['SMTP_USER'] = row[30] + app.config['SNOW_ENABLED'] = row[38] + app.config['SNOW_CLIENT_ID'] = row[31] + app.config['SNOW_CLIENT_SECRET'] = row[32] + app.config['SNOW_INSTANCE_NAME'] = row[33] + app.config['SNOW_PASSWORD'] = row[34] + app.config['SNOW_USERNAME'] = row[35] + app.config['VERSION'] = row[36] + except: + print('AppConfig Database table is either unreachable or not setup.') + +getPersistentConfig() def train_model(): try: @@ -337,7 +377,7 @@ def rsa_long_decrypt(priv_obj, msg, length=256): def get_jenkins_data(): - user_check = JENKINS_USER + user_check = app.config['JENKINS_USER'] if user_check != 'changeme': app.logger.info('Getting Jenkins Data') cur, db = connect_to_db() @@ -452,5 +492,5 @@ def get_jenkins_data(): # Call the Jobs Here # train_model_every_six_hours() -if JENKINS_ENABLED == 'yes': +if app.config['JENKINS_ENABLED'] == 'yes': get_jenkins_data_every_hour() diff --git a/src/vr/admin/auth_functions.py b/src/vr/admin/auth_functions.py index 20ddf7ca..885020c6 100644 --- a/src/vr/admin/auth_functions.py +++ b/src/vr/admin/auth_functions.py @@ -1,7 +1,7 @@ import jwt from time import time from vr.functions.mysql_db import connect_to_db -from config_engine import ENV +from vr import app # Error handler @@ -49,7 +49,7 @@ def create_api_key(user_id, otp_secret, expires_in=2592000): def verify_api_key(token): try: cur, db = connect_to_db() - if ENV == 'test': + if app.config['ENV'] == 'test': sql = 'SELECT oc.user_id, u.is_admin FROM oauth2_client oc JOIN oauth2_token ot ON oc.client_id=ot.client_id JOIN User u ON oc.user_id=u.id WHERE ot.id=?' else: sql = 'SELECT oc.user_id, u.is_admin FROM oauth2_client oc JOIN oauth2_token ot ON oc.client_id=ot.client_id JOIN User u ON oc.user_id=u.id WHERE ot.id=%s' diff --git a/src/vr/admin/email_alerts.py b/src/vr/admin/email_alerts.py index a1c48da3..698b5138 100644 --- a/src/vr/admin/email_alerts.py +++ b/src/vr/admin/email_alerts.py @@ -1,7 +1,7 @@ import smtplib from email.mime import multipart from email.mime import text as mimetext -from config_engine import SMTP_HOST, SMTP_USER, SMTP_PASSWORD, SMTP_ADMIN_EMAIL +from vr import app def send_email(msg_fromaddr, msg_toaddr, msg_subject, msg_body): @@ -11,9 +11,9 @@ def send_email(msg_fromaddr, msg_toaddr, msg_subject, msg_body): msg['To'] = msg_toaddr msg['Subject'] = msg_subject msg.attach(mimetext.MIMEText(message, 'html')) - server = smtplib.SMTP(SMTP_HOST) + server = smtplib.SMTP(app.config['SMTP_HOST']) server.starttls() - server.login(SMTP_USER, SMTP_PASSWORD) + server.login(app.config['SMTP_USER'], app.config['SMTP_PASSWORD']) server.ehlo() text = msg.as_string() server.sendmail(msg_fromaddr, msg_toaddr, text) @@ -24,7 +24,7 @@ def send_registration_email(ext_url, username, first_name, last_name, token, ema msg_subject = "SecuSphere User Registration" msg_body = generate_registration_msg(ext_url, username, first_name, last_name, token) try: - send_email(SMTP_ADMIN_EMAIL, email_to, msg_subject, msg_body) + send_email(app.config['SMTP_ADMIN_EMAIL'], email_to, msg_subject, msg_body) except: return 'error' diff --git a/src/vr/admin/models.py b/src/vr/admin/models.py index 89785772..d5d5e4ad 100644 --- a/src/vr/admin/models.py +++ b/src/vr/admin/models.py @@ -3,7 +3,7 @@ from flask_login import UserMixin from vr import db, app from vr.functions.mysql_db import connect_to_db -from datetime import datetime, timedelta +from datetime import datetime import jwt from vr.admin.helper_functions import hash_password,verify_password from vr.admin.functions import db_connection_handler @@ -17,8 +17,7 @@ OAuth2AuthorizationCodeMixin, OAuth2TokenMixin, ) -from config_engine import AUTH_TYPE -if AUTH_TYPE == 'ldap': +if app.config['AUTH_TYPE'] == 'ldap': from vr import ldap_manager if app.config['RUNTIME_ENV'] == 'test': @@ -190,11 +189,11 @@ def verify_username_token(self, token, given_id): else: return -if AUTH_TYPE == 'local' or AUTH_TYPE == 'azuread': +if app.config['AUTH_TYPE'] == 'local' or app.config['AUTH_TYPE'] == 'azuread': @login_manager.user_loader def load_user(id): return User.query.get(int(id)) -elif AUTH_TYPE == 'ldap': +elif app.config['AUTH_TYPE'] == 'ldap': # User Loader for LDAP @login_manager.user_loader def load_user(user_id): diff --git a/src/vr/admin/routes/forgotpw.py b/src/vr/admin/routes/forgotpw.py index 2d12cd59..f6d50228 100644 --- a/src/vr/admin/routes/forgotpw.py +++ b/src/vr/admin/routes/forgotpw.py @@ -6,7 +6,6 @@ from vr.admin.email_alerts import send_email, generate_evnt_msg from vr.functions.timefunctions import return_datetime_now from vr.admin.helper_functions import hash_password -from config_engine import SMTP_ADMIN_EMAIL from vr.admin.functions import db_connection_handler @@ -32,7 +31,7 @@ def forgotpw(): action_list = [action] st = 'n' msg_body = generate_evnt_msg(msg_subject, now, evt_list, action_list, st) - msg_fromaddr = SMTP_ADMIN_EMAIL + msg_fromaddr = app.config['SMTP_ADMIN_EMAIL'] try: send_email(msg_fromaddr, email, msg_subject, msg_body) warnmsg = ('pwresetemail', 'success') diff --git a/src/vr/admin/routes/forgotun.py b/src/vr/admin/routes/forgotun.py index 80c52425..d8a0d2fa 100644 --- a/src/vr/admin/routes/forgotun.py +++ b/src/vr/admin/routes/forgotun.py @@ -5,7 +5,6 @@ from vr.admin.models import User, LoginForm from vr.admin.email_alerts import send_email, generate_evnt_msg from vr.functions.timefunctions import return_datetime_now -from config_engine import SMTP_ADMIN_EMAIL NAV_CAT= { "name": "Admin", "url": "admin.admin_dashboard"} @@ -28,7 +27,7 @@ def forgotun(): action_list = [action] st = 'n' msg_body = generate_evnt_msg(msg_subject,now,evt_list,action_list,st) - msg_fromaddr = SMTP_ADMIN_EMAIL + msg_fromaddr = app.config['SMTP_ADMIN_EMAIL'] try: send_email(msg_fromaddr, email, msg_subject, msg_body) warnmsg = ('pwresetemail', 'success') diff --git a/src/vr/admin/routes/login.py b/src/vr/admin/routes/login.py index 9eed58a7..d7f641f1 100644 --- a/src/vr/admin/routes/login.py +++ b/src/vr/admin/routes/login.py @@ -8,10 +8,9 @@ from vr.admin.models import User, LoginForm, AuthAttempts, AppConfig from vr.admin.functions import _auth_user, _entity_permissions_filter, _entity_page_permissions_filter, check_lockout, log_failed_attempt from vr.admin.functions import db_connection_handler -from config_engine import AUTH_TYPE -if AUTH_TYPE == 'ldap': +if app.config['AUTH_TYPE'] == 'ldap': from flask_ldap3_login.forms import LDAPLoginForm -elif AUTH_TYPE == 'azuread': +elif app.config['AUTH_TYPE'] == 'azuread': import requests import msal from vr import _build_auth_code_flow, _load_cache, _save_cache, _build_msal_app, _get_token_from_cache @@ -35,7 +34,7 @@ def login(): return redirect(url_for('admin.register')) ad_auth_url = None warnmsg = '' - if AUTH_TYPE == 'local': + if app.config['AUTH_TYPE'] == 'local': if current_user.is_authenticated: flash('You are already logged in.', 'danger') return redirect(url_for('assets.all_applications')) @@ -60,7 +59,7 @@ def login(): mfa_password = resp[2] # attempt to log the user in return _login_attempt(user, username, password, userid, form, mfa_password) - elif AUTH_TYPE == 'ldap': + elif app.config['AUTH_TYPE'] == 'ldap': form = LDAPLoginForm() if form.validate_on_submit(): # Log the user in @@ -71,15 +70,15 @@ def login(): # Print the form errors print("Form validation failed with errors:", form.errors) return render_template(LDAP_LOGIN_TEMPLATE, form=form, errors=form.errors) - elif AUTH_TYPE == 'azuread': + elif app.config['AUTH_TYPE'] == 'azuread': form = LoginForm(request.form) session["flow"] = _build_auth_code_flow(scopes=app.config['SCOPE']) ad_auth_url = session["flow"]["auth_uri"] if form.errors: warnmsg = (form.errors, 'danger') - return render_template(LOGIN_TEMPLATE, form=form, warnmsg=warnmsg, auth_type=AUTH_TYPE, auth_url=ad_auth_url) + return render_template(LOGIN_TEMPLATE, form=form, warnmsg=warnmsg, auth_type=app.config['AUTH_TYPE'], auth_url=ad_auth_url) -if AUTH_TYPE == 'azuread': +if app.config['AUTH_TYPE'] == 'azuread': @app.route(app.config['REDIRECT_PATH']) # Its absolute URL must match your app's redirect_uri set in AAD def authorized(): try: diff --git a/src/vr/admin/routes/logout.py b/src/vr/admin/routes/logout.py index 218cd357..781302c9 100644 --- a/src/vr/admin/routes/logout.py +++ b/src/vr/admin/routes/logout.py @@ -1,20 +1,20 @@ from flask_login import logout_user, login_required from flask import session, redirect, url_for from vr.admin import admin -from config_engine import AUTH_TYPE +from vr import app NAV_CAT= { "name": "Admin", "url": "admin.admin_dashboard"} -if AUTH_TYPE == 'local': +if app.config['AUTH_TYPE'] == 'local': @admin.route('/logout') @login_required def logout(): logout_user() del session['username'] return redirect(url_for('admin.login')) -elif AUTH_TYPE == 'azuread': +elif app.config['AUTH_TYPE'] == 'azuread': @admin.route('/logout') def logout(): logout_user() diff --git a/src/vr/admin/routes/register.py b/src/vr/admin/routes/register.py index 38f0b3f8..1f6f38a8 100644 --- a/src/vr/admin/routes/register.py +++ b/src/vr/admin/routes/register.py @@ -13,7 +13,6 @@ from vr.admin.helper_functions import hash_password from vr.admin.email_alerts import send_registration_email from vr.functions.initial_setup import setup_core_db_tables, generate_key_pair -from config_engine import ENV from vr.db_models.setup_2 import _init_db @@ -115,7 +114,7 @@ def register_submit(): _init_db(db=db) generate_key_pair() - setup_core_db_tables(ENV) + setup_core_db_tables(app.config['ENV']) admin_role = UserRoles.query.filter_by(name='Admin').first() ura = UserRoleAssignments(user_id=user.id, role_id=admin_role.id) db.session.add(ura) diff --git a/src/vr/admin/routes/settings.py b/src/vr/admin/routes/settings.py index fea3e3b5..532ae0d5 100644 --- a/src/vr/admin/routes/settings.py +++ b/src/vr/admin/routes/settings.py @@ -5,16 +5,8 @@ # Start of Entity-specific Imports from vr.admin import admin from vr.admin.functions import _auth_user, check_menu_tour_init -from config_engine import ENV, PROD_DB_URI, AUTH_TYPE, APP_EXT_URL, LDAP_HOST, LDAP_PORT, LDAP_BASE_DN, \ - LDAP_USER_DN, LDAP_GROUP_DN, LDAP_USER_RDN_ATTR, LDAP_USER_LOGIN_ATTR, LDAP_BIND_USER_DN, LDAP_BIND_USER_PASSWORD, \ - AZAD_CLIENT_ID, AZAD_CLIENT_SECRET, AZAD_AUTHORITY, JENKINS_USER, AZURE_KEYVAULT_NAME, INSECURE_OAUTH, \ - JENKINS_HOST, JENKINS_KEY, JENKINS_PROJECT, JENKINS_STAGING_PROJECT, JENKINS_TOKEN, SMTP_ADMIN_EMAIL, \ - SMTP_HOST, SMTP_PASSWORD, SMTP_USER, SNOW_CLIENT_ID, SNOW_CLIENT_SECRET, SNOW_INSTANCE_NAME, SNOW_PASSWORD, \ - SNOW_USERNAME, VERSION, JENKINS_ENABLED, SNOW_ENABLED -from flask_sqlalchemy import SQLAlchemy from vr.admin.models import AppConfig from vr.admin.functions import db_connection_handler -from sqlalchemy import text NAV = { @@ -44,7 +36,7 @@ def settings(): AppConfig.AZAD_CLIENT_ID: all["AZAD_CLIENT_ID"], AppConfig.AZAD_CLIENT_SECRET: all["AZAD_CLIENT_SECRET"], AppConfig.AZURE_KEYVAULT_NAME: all["AZURE_KEYVAULT_NAME"], - AppConfig.ENV: ENV, + AppConfig.ENV: app.config['ENV'], AppConfig.INSECURE_OAUTH: all["INSECURE_OAUTH"], AppConfig.JENKINS_HOST: all["JENKINS_HOST"], AppConfig.JENKINS_KEY: all["JENKINS_KEY"], @@ -71,7 +63,7 @@ def settings(): AppConfig.SNOW_INSTANCE_NAME: all["SNOW_INSTANCE_NAME"], AppConfig.SNOW_PASSWORD: all["SNOW_PASSWORD"], AppConfig.SNOW_USERNAME: all["SNOW_USERNAME"], - AppConfig.VERSION: VERSION, + AppConfig.VERSION: app.config['VERSION'], } if not app_config.settings_initialized: update_json[AppConfig.settings_initialized] = True @@ -88,7 +80,7 @@ def settings(): "AZAD_CLIENT_ID": all["AZAD_CLIENT_ID"], "AZAD_CLIENT_SECRET": all["AZAD_CLIENT_SECRET"], "AZURE_KEYVAULT_NAME": all["AZURE_KEYVAULT_NAME"], - "ENV": ENV, + "ENV": app.config['ENV'], "INSECURE_OAUTH": all["INSECURE_OAUTH"], "JENKINS_HOST": all["JENKINS_HOST"], "JENKINS_KEY": all["JENKINS_KEY"], @@ -115,7 +107,7 @@ def settings(): "SNOW_INSTANCE_NAME": all["SNOW_INSTANCE_NAME"], "SNOW_PASSWORD": all["SNOW_PASSWORD"], "SNOW_USERNAME": all["SNOW_USERNAME"], - "VERSION": VERSION, + "VERSION": app.config['VERSION'], } else: app_config = AppConfig.query.first() @@ -160,42 +152,42 @@ def settings(): } else: current_settings = { - "JENKINS_ENABLED": JENKINS_ENABLED, - "SNOW_ENABLED": SNOW_ENABLED, - "APP_EXT_URL": APP_EXT_URL, - "AUTH_TYPE": AUTH_TYPE, - "AZAD_AUTHORITY":AZAD_AUTHORITY, - "AZAD_CLIENT_ID": AZAD_CLIENT_ID, - "AZAD_CLIENT_SECRET": AZAD_CLIENT_SECRET, - "AZURE_KEYVAULT_NAME": AZURE_KEYVAULT_NAME, - "ENV": ENV, - "INSECURE_OAUTH": INSECURE_OAUTH, - "JENKINS_HOST": JENKINS_HOST, - "JENKINS_KEY": JENKINS_KEY, - "JENKINS_PROJECT": JENKINS_PROJECT, - "JENKINS_STAGING_PROJECT": JENKINS_STAGING_PROJECT, - "JENKINS_USER": JENKINS_USER, - "JENKINS_TOKEN": JENKINS_TOKEN, - "LDAP_BASE_DN": LDAP_BASE_DN, - "LDAP_BIND_USER_DN": LDAP_BIND_USER_DN, - "LDAP_BIND_USER_PASSWORD": LDAP_BIND_USER_PASSWORD, - "LDAP_GROUP_DN": LDAP_GROUP_DN, - "LDAP_HOST": LDAP_HOST, - "LDAP_PORT": LDAP_PORT, - "LDAP_USER_DN": LDAP_USER_DN, - "LDAP_USER_LOGIN_ATTR": LDAP_USER_LOGIN_ATTR, - "LDAP_USER_RDN_ATTR": LDAP_USER_RDN_ATTR, - "PROD_DB_URI": PROD_DB_URI, - "SMTP_ADMIN_EMAIL": SMTP_ADMIN_EMAIL, - "SMTP_HOST": SMTP_HOST, - "SMTP_USER": SMTP_USER, - "SMTP_PASSWORD": SMTP_PASSWORD, - "SNOW_CLIENT_ID": SNOW_CLIENT_ID, - "SNOW_CLIENT_SECRET": SNOW_CLIENT_SECRET, - "SNOW_INSTANCE_NAME": SNOW_INSTANCE_NAME, - "SNOW_USERNAME": SNOW_USERNAME, - "SNOW_PASSWORD": SNOW_PASSWORD, - "VERSION": VERSION, + "JENKINS_ENABLED": app.config['JENKINS_ENABLED'], + "SNOW_ENABLED": app.config['SNOW_ENABLED'], + "APP_EXT_URL": app.config['APP_EXT_URL'], + "AUTH_TYPE": app.config['AUTH_TYPE'], + "AZAD_AUTHORITY": app.config['AZAD_AUTHORITY'], + "AZAD_CLIENT_ID": app.config['AZAD_CLIENT_ID'], + "AZAD_CLIENT_SECRET": app.config['AZAD_CLIENT_SECRET'], + "AZURE_KEYVAULT_NAME": app.config['AZURE_KEYVAULT_NAME'], + "ENV": app.config['ENV'], + "INSECURE_OAUTH": app.config['INSECURE_OAUTH'], + "JENKINS_HOST": app.config['JENKINS_HOST'], + "JENKINS_KEY": app.config['JENKINS_KEY'], + "JENKINS_PROJECT": app.config['JENKINS_PROJECT'], + "JENKINS_STAGING_PROJECT": app.config['JENKINS_STAGING_PROJECT'], + "JENKINS_USER": app.config['JENKINS_USER'], + "JENKINS_TOKEN": app.config['JENKINS_TOKEN'], + "LDAP_BASE_DN": app.config['LDAP_BASE_DN'], + "LDAP_BIND_USER_DN": app.config['LDAP_BIND_USER_DN'], + "LDAP_BIND_USER_PASSWORD": app.config['LDAP_BIND_USER_PASSWORD'], + "LDAP_GROUP_DN": app.config['LDAP_GROUP_DN'], + "LDAP_HOST": app.config['LDAP_HOST'], + "LDAP_PORT": app.config['LDAP_PORT'], + "LDAP_USER_DN": app.config['LDAP_USER_DN'], + "LDAP_USER_LOGIN_ATTR": app.config['LDAP_USER_LOGIN_ATTR'], + "LDAP_USER_RDN_ATTR": app.config['LDAP_USER_RDN_ATTR'], + "PROD_DB_URI": app.config['PROD_DB_URI'], + "SMTP_ADMIN_EMAIL": app.config['SMTP_ADMIN_EMAIL'], + "SMTP_HOST": app.config['SMTP_HOST'], + "SMTP_USER": app.config['SMTP_USER'], + "SMTP_PASSWORD": app.config['SMTP_PASSWORD'], + "SNOW_CLIENT_ID": app.config['SNOW_CLIENT_ID'], + "SNOW_CLIENT_SECRET": app.config['SNOW_CLIENT_SECRET'], + "SNOW_INSTANCE_NAME": app.config['SNOW_INSTANCE_NAME'], + "SNOW_USERNAME": app.config['SNOW_USERNAME'], + "SNOW_PASSWORD": app.config['SNOW_PASSWORD'], + "VERSION": app.config['VERSION'], } cat_general = [ 'APP_EXT_URL', @@ -257,7 +249,7 @@ def set_env_variables(form): os.environ['AZAD_CLIENT_ID'] = form["AZAD_CLIENT_ID"] os.environ['AZAD_CLIENT_SECRET'] = form["AZAD_CLIENT_SECRET"] os.environ['AZURE_KEYVAULT_NAME'] = form["AZURE_KEYVAULT_NAME"] - os.environ['ENV'] = ENV + os.environ['ENV'] = app.config['ENV'] os.environ['INSECURE_OAUTH'] = form["INSECURE_OAUTH"] os.environ['JENKINS_ENABLED'] = form["JENKINS_ENABLED"] os.environ['JENKINS_HOST'] = form["JENKINS_HOST"] @@ -286,7 +278,43 @@ def set_env_variables(form): os.environ['SNOW_INSTANCE_NAME'] = form["SNOW_INSTANCE_NAME"] os.environ['SNOW_PASSWORD'] = form["SNOW_PASSWORD"] os.environ['SNOW_USERNAME'] = form["SNOW_USERNAME"] - os.environ['VERSION'] = VERSION + os.environ['VERSION'] = app.config['VERSION'] + app.config['APP_EXT_URL'] = form["APP_EXT_URL"] + app.config['AUTH_TYPE'] = form["AUTH_TYPE"] + app.config['AZAD_AUTHORITY'] = form["AZAD_AUTHORITY"] + app.config['AZAD_CLIENT_ID'] = form["AZAD_CLIENT_ID"] + app.config['AZAD_CLIENT_SECRET'] = form["AZAD_CLIENT_SECRET"] + app.config['AZURE_KEYVAULT_NAME'] = form["AZURE_KEYVAULT_NAME"] + app.config['ENV'] = app.config['ENV'] + app.config['INSECURE_OAUTH'] = form["INSECURE_OAUTH"] + app.config['JENKINS_ENABLED'] = form["JENKINS_ENABLED"] + app.config['JENKINS_HOST'] = form["JENKINS_HOST"] + app.config['JENKINS_KEY'] = form["JENKINS_KEY"] + app.config['JENKINS_PROJECT'] = form["JENKINS_PROJECT"] + app.config['JENKINS_STAGING_PROJECT'] = form["JENKINS_STAGING_PROJECT"] + app.config['JENKINS_TOKEN'] = form["JENKINS_TOKEN"] + app.config['JENKINS_USER'] = form["JENKINS_USER"] + app.config['LDAP_BASE_DN'] = form["LDAP_BASE_DN"] + app.config['LDAP_BIND_USER_DN'] = form["LDAP_BIND_USER_DN"] + app.config['LDAP_BIND_USER_PASSWORD'] = form["LDAP_BIND_USER_PASSWORD"] + app.config['LDAP_GROUP_DN'] = form["LDAP_GROUP_DN"] + app.config['LDAP_HOST'] = form["LDAP_HOST"] + app.config['LDAP_PORT'] = form["LDAP_PORT"] + app.config['LDAP_USER_DN'] = form["LDAP_USER_DN"] + app.config['LDAP_USER_LOGIN_ATTR'] = form["LDAP_USER_LOGIN_ATTR"] + app.config['LDAP_USER_RDN_ATTR'] = form["LDAP_USER_RDN_ATTR"] + app.config['PROD_DB_URI'] = form["PROD_DB_URI"] + app.config['SMTP_ADMIN_EMAIL'] = form["SMTP_ADMIN_EMAIL"] + app.config['SMTP_HOST'] = form["SMTP_HOST"] + app.config['SMTP_PASSWORD'] = form["SMTP_PASSWORD"] + app.config['SMTP_USER'] = form["SMTP_USER"] + app.config['SNOW_ENABLED'] = form["SNOW_ENABLED"] + app.config['SNOW_CLIENT_ID'] = form["SNOW_CLIENT_ID"] + app.config['SNOW_CLIENT_SECRET'] = form["SNOW_CLIENT_SECRET"] + app.config['SNOW_INSTANCE_NAME'] = form["SNOW_INSTANCE_NAME"] + app.config['SNOW_PASSWORD'] = form["SNOW_PASSWORD"] + app.config['SNOW_USERNAME'] = form["SNOW_USERNAME"] + app.config['VERSION'] = app.config['VERSION'] @admin.route('/dangerous/delete_all', methods=['POST']) @@ -300,7 +328,7 @@ def delete_all_data(): nav_subsubcat='', nav_curpage={"name": "Unauthorized"}) try: - if ENV == 'test': + if app.config['ENV'] == 'test': # Ensure all connections to the database are closed db.session.close() db.engine.dispose() diff --git a/src/vr/admin/routes/users.py b/src/vr/admin/routes/users.py index 5e461b33..95f12ae3 100644 --- a/src/vr/admin/routes/users.py +++ b/src/vr/admin/routes/users.py @@ -8,7 +8,6 @@ from sqlalchemy import text from flask import request, render_template, session, redirect, url_for, json from flask_login import login_required -from config_engine import AUTH_TYPE from vr.functions.table_functions import load_table, update_table from vr.admin.email_alerts import send_registration_email from vr.assets.model.businessapplications import BusinessApplications @@ -296,7 +295,7 @@ def add_new_user(): first_name=firstname, last_name=lastname, is_active=False, - auth_type=AUTH_TYPE, + auth_type=app.config['AUTH_TYPE'], otp_secret=otp_secret, user_type='system', avatar_path='/static/images/default_profile_avatar.jpg' diff --git a/src/vr/api/integrations/servicenow.py b/src/vr/api/integrations/servicenow.py index 5f76555a..ec06d99f 100644 --- a/src/vr/api/integrations/servicenow.py +++ b/src/vr/api/integrations/servicenow.py @@ -1,13 +1,12 @@ from flask import jsonify, request import requests import json +from vr import app from vr.api import api from vr.admin.oauth2 import require_oauth from authlib.integrations.flask_oauth2 import current_token from vr.admin.auth_functions import verify_api_key, get_token_auth_header from vr.functions.routing_functions import check_entity_permissions -from vr.assets.model.applicationprofiles import ApplicationProfiles, ApplicationProfilesSchema -from config_engine import SNOW_PASSWORD, SNOW_CLIENT_SECRET, SNOW_INSTANCE_NAME, SNOW_CLIENT_ID, SNOW_USERNAME ERROR_RESP = "Error: Invalid API Request" @@ -184,11 +183,11 @@ def create_new_collaboration_tools(snow_obj, app_name, app_desc): return sys_id_map # ServiceNow instance details -INSTANCE_NAME = SNOW_INSTANCE_NAME -CLIENT_ID = SNOW_CLIENT_ID -CLIENT_SECRET = SNOW_CLIENT_SECRET -USERNAME = SNOW_USERNAME -PASSWORD = SNOW_PASSWORD +INSTANCE_NAME = app.config['SNOW_INSTANCE_NAME'] +CLIENT_ID = app.config['SNOW_CLIENT_ID'] +CLIENT_SECRET = app.config['SNOW_CLIENT_SECRET'] +USERNAME = app.config['SNOW_USERNAME'] +PASSWORD = app.config['SNOW_PASSWORD'] TOKEN_URL = f'https://{INSTANCE_NAME}.service-now.com/oauth_token.do' TOKEN_DATA = { diff --git a/src/vr/api/vulns/jenkins_webhook.py b/src/vr/api/vulns/jenkins_webhook.py index 28f1824e..0b2e8b2d 100644 --- a/src/vr/api/vulns/jenkins_webhook.py +++ b/src/vr/api/vulns/jenkins_webhook.py @@ -2,10 +2,11 @@ import datetime from threading import Thread from flask import jsonify, request, json -from vr import db +from vr import db, app from vr.api import api from requests.auth import HTTPBasicAuth -from config_engine import JENKINS_USER, JENKINS_KEY, JENKINS_PROJECT, JENKINS_HOST, JENKINS_TOKEN +# from config_engine import JENKINS_USER, JENKINS_KEY, JENKINS_PROJECT, JENKINS_HOST, JENKINS_TOKEN +from config_engine import getConfigs from vr.admin.oauth2 import require_oauth from sqlalchemy import text from vr.assets.model.cicdpipelinebuilds import CICDPipelineBuilds @@ -25,6 +26,7 @@ @api.route('/api/jenkins_webhook', methods=['POST']) @require_oauth('write:vulnerabilities') def jenkins_webhook(): + getConfigs(app.config) all = request.form payload_dict = json.loads(all['payload']) ref = payload_dict['ref'] diff --git a/src/vr/api/vulns/vulnerabilities.py b/src/vr/api/vulns/vulnerabilities.py index 68360c8b..b151f5bf 100644 --- a/src/vr/api/vulns/vulnerabilities.py +++ b/src/vr/api/vulns/vulnerabilities.py @@ -16,7 +16,6 @@ from vr.admin.oauth2 import require_oauth from vr.admin.functions import db_connection_handler from authlib.integrations.flask_oauth2 import current_token -from config_engine import ENV import re @@ -295,7 +294,7 @@ def _add_new_vulns(new_vulns, engine): def _setup_duplicate_vulns(source_type, dup_vulns): sourced_dup_vulns = [] for vuln in dup_vulns: - if ENV == 'test': + if app.config['ENV'] == 'test': vuln['LastModifiedDate'] = datetime.datetime.utcnow().replace(microsecond=0) if vuln['ReleaseDate']: vuln['ReleaseDate'] = datetime.datetime.strptime(vuln['ReleaseDate'], '%Y-%m-%d %H:%M:%S') diff --git a/src/vr/db_models/setup.py b/src/vr/db_models/setup.py index b36fdc22..cb37b344 100644 --- a/src/vr/db_models/setup.py +++ b/src/vr/db_models/setup.py @@ -1,11 +1,6 @@ from datetime import datetime from sqlalchemy.types import TEXT, DECIMAL from flask import jsonify -from config_engine import ENV -if ENV == 'test': - from sqlalchemy.dialects.sqlite import TEXT as LONGTEXT -else: - from sqlalchemy.dialects.mysql import LONGTEXT from flask_sqlalchemy import SQLAlchemy from sqlalchemy.dialects import mysql from flask_login import UserMixin @@ -176,9 +171,9 @@ class TmControls(db.Model): __tablename__ = 'TmControls' ID = db.Column(db.Integer, primary_key=True) AddDate = db.Column(db.DateTime, index=True, default=datetime.utcnow, nullable=False) - Control = db.Column(LONGTEXT) + Control = db.Column(db.String(20000)) Type = db.Column(db.String(8)) - Description = db.Column(LONGTEXT) + Description = db.Column(db.String(20000)) Lambda = db.Column(db.String(1)) Process = db.Column(db.String(1)) Server = db.Column(db.String(1)) diff --git a/src/vr/db_models/setup_2.py b/src/vr/db_models/setup_2.py index d47ba210..0d98c122 100644 --- a/src/vr/db_models/setup_2.py +++ b/src/vr/db_models/setup_2.py @@ -2,8 +2,8 @@ from sqlalchemy.types import TEXT, DECIMAL from sqlalchemy import MetaData from vr.admin.functions import db_connection_handler -from config_engine import ENV -if ENV == 'test': +from vr import app +if app.config['ENV'] == 'test': from sqlalchemy.dialects.sqlite import TEXT as LONGTEXT else: from sqlalchemy.dialects.mysql import LONGTEXT diff --git a/src/vr/orchestration/web/pipeline_jobs.py b/src/vr/orchestration/web/pipeline_jobs.py index e9fcc7ee..2ef5390b 100644 --- a/src/vr/orchestration/web/pipeline_jobs.py +++ b/src/vr/orchestration/web/pipeline_jobs.py @@ -11,7 +11,6 @@ from vr.orchestration.model.cicdpipelines import CICDPipelines, CICDPipelinesSchema from vr.orchestration.model.pipelinejobs import PipelineJobs, PipelineJobsSchema from vr.orchestration.web.pipeline_stage_data import OPTS -from config_engine import JENKINS_USER, JENKINS_KEY, JENKINS_STAGING_PROJECT, JENKINS_HOST, JENKINS_TOKEN NAV = { @@ -248,7 +247,7 @@ def validate_cicd_pipeline_stage(appid): "Content-Type": "application/x-www-form-urlencoded" } data = { - 'token': JENKINS_TOKEN, + 'token': app.config['JENKINS_TOKEN'], 'GIT_URL': git_url, 'GIT_BRANCH': git_branch, 'APP_NAME': app_name, @@ -261,8 +260,8 @@ def validate_cicd_pipeline_stage(appid): 'TARGET_URL': target_url } - url = f'{JENKINS_HOST}/job/{JENKINS_STAGING_PROJECT}/buildWithParameters' - resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(JENKINS_USER, JENKINS_KEY)) + url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_STAGING_PROJECT']}/buildWithParameters" + resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) return str(200) diff --git a/src/vr/templates/admin/settings.html b/src/vr/templates/admin/settings.html index a7564e1a..f5da3318 100644 --- a/src/vr/templates/admin/settings.html +++ b/src/vr/templates/admin/settings.html @@ -134,7 +134,7 @@

General Settings

{% elif key == "PROD_DB_URI" %} -
+
{% elif key == "ENV" or key == "VERSION" %} {% else %} @@ -176,7 +176,7 @@

SMTP Settings

{% if key == 'SMTP_PASSWORD' %} -
+
{% else %} {% endif %} @@ -199,10 +199,10 @@

Jenkins Settings

{% elif key == 'JENKINS_KEY' %} -
+
{% elif key == 'JENKINS_TOKEN' %} -
+
{% else %} @@ -229,10 +229,10 @@

ServiceNOW Settings

{% elif key == 'SNOW_CLIENT_SECRET' %} -
+
{% elif key == 'SNOW_PASSWORD' %} -
+
{% else %} diff --git a/src/vr/vulns/web/findings.py b/src/vr/vulns/web/findings.py index 8c9938c8..06d44322 100644 --- a/src/vr/vulns/web/findings.py +++ b/src/vr/vulns/web/findings.py @@ -25,7 +25,6 @@ import base64 from io import StringIO from flask import Response -from config_engine import ENV from vr.functions.ml_functions import predict_vuln_validity from vr.vulns.model.cvssbasescoresv3 import CVSSBaseScoresV3 from vr.vulns.model.cvssbasescoresv3extensions import CVSSBaseScoresV3Extensions @@ -42,7 +41,7 @@ UNAUTH_STATUS = "403.html" SERVER_ERR_STATUS = "500.html" VULN_STATUS_IS_NOT_CLOSED = "Vulnerabilities.Status NOT LIKE 'Closed-%' AND Vulnerabilities.Status NOT LIKE 'Open-RiskAccepted-%'" -test = ENV +test = app.config['ENV'] if test == 'test': ISO_FORMAT = "%Y-%m-%dT%H:%M:%S.%f" else: diff --git a/src/vr/vulns/web/testing.py b/src/vr/vulns/web/testing.py index 32e604b8..c69f7122 100644 --- a/src/vr/vulns/web/testing.py +++ b/src/vr/vulns/web/testing.py @@ -11,8 +11,8 @@ from vr.vulns.model.vulnerabilityscans import VulnerabilityScans, VulnerabilityScansSchema from vr.functions.table_functions import load_table, update_table from requests.auth import HTTPBasicAuth -from config_engine import JENKINS_USER, JENKINS_KEY, JENKINS_PROJECT, JENKINS_HOST, JENKINS_TOKEN from vr.assets.model.applicationprofiles import ApplicationProfiles, ApplicationProfilesSchema +from vr import app NAV = { @@ -115,14 +115,14 @@ def on_demand_testing(): "Content-Type": "application/x-www-form-urlencoded" } data = { - 'token': JENKINS_TOKEN, + 'token': app.config['JENKINS_TOKEN'], 'GIT_URL': git_url, 'TESTS': tests_to_run.upper(), 'GIT_BRANCH': git_branch, 'APP_NAME': app_name } - url = f'{JENKINS_HOST}/job/{JENKINS_PROJECT}/buildWithParameters' - resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(JENKINS_USER, JENKINS_KEY)) + url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" + resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) return redirect(request.referrer) From e5d1cc49f0be5bb59605abd342b8064b58e07c71 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 07:55:31 -0700 Subject: [PATCH 077/197] Release/0.1.0 beta/prod azure (#518) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile * Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * Feature/update settings function (#501) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * Feature/update release based db settings (#503) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * Feature/update release based db settings (#505) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#507) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#509) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Feature/fix syntax error (#511) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Feature/fix syntax error (#513) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Feature/fix syntax error (#515) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * Feature/fix syntax error (#517) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py --- src/config_engine.py | 430 +++++++++++----------- src/run.py | 3 +- src/vr/__init__.py | 102 +++-- src/vr/admin/auth_functions.py | 4 +- src/vr/admin/email_alerts.py | 8 +- src/vr/admin/models.py | 9 +- src/vr/admin/routes/forgotpw.py | 3 +- src/vr/admin/routes/forgotun.py | 3 +- src/vr/admin/routes/login.py | 15 +- src/vr/admin/routes/logout.py | 6 +- src/vr/admin/routes/register.py | 3 +- src/vr/admin/routes/settings.py | 130 ++++--- src/vr/admin/routes/users.py | 3 +- src/vr/api/integrations/servicenow.py | 13 +- src/vr/api/vulns/jenkins_webhook.py | 6 +- src/vr/api/vulns/vulnerabilities.py | 3 +- src/vr/db_models/setup.py | 9 +- src/vr/db_models/setup_2.py | 4 +- src/vr/orchestration/web/pipeline_jobs.py | 7 +- src/vr/templates/admin/settings.html | 12 +- src/vr/vulns/web/findings.py | 3 +- src/vr/vulns/web/testing.py | 8 +- 22 files changed, 421 insertions(+), 363 deletions(-) diff --git a/src/config_engine.py b/src/config_engine.py index 07400d06..7ee859ad 100644 --- a/src/config_engine.py +++ b/src/config_engine.py @@ -14,98 +14,229 @@ from settings import SET_SNOW_INSTANCE_NAME, SET_SNOW_CLIENT_ID, SET_SNOW_CLIENT_SECRET, SET_SNOW_USERNAME, SET_SNOW_PASSWORD, SET_SNOW_CLIENT_SECRET_REF, SET_SNOW_PASSWORD_REF -VERSION = '0.1.0-beta' - -if os.getenv('AZURE_KEYVAULT_NAME'): - AZURE_KEYVAULT_NAME = os.getenv('AZURE_KEYVAULT_NAME') -else: - AZURE_KEYVAULT_NAME = SET_AZURE_KEYVAULT_NAME - -if os.getenv('AUTH_TYPE'): - AUTH_TYPE = os.getenv('AUTH_TYPE') -else: - AUTH_TYPE = SET_AUTH_TYPE - -if os.getenv('INSECURE_OAUTH'): - INSECURE_OAUTH = os.getenv('INSECURE_OAUTH') -else: - INSECURE_OAUTH = SET_INSECURE_OAUTH - -if INSECURE_OAUTH: - os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1' - -if os.getenv('APP_EXT_URL'): - APP_EXT_URL = os.getenv('APP_EXT_URL') -else: - APP_EXT_URL = SET_APP_EXT_URL - -if os.getenv('SMTP_HOST'): - SMTP_HOST = os.getenv('SMTP_HOST') -else: - SMTP_HOST = SET_SMTP_HOST - -if os.getenv('SMTP_USER'): - SMTP_USER = os.getenv('SMTP_USER') -else: - SMTP_USER = SET_SMTP_USER - -if os.getenv('SMTP_ADMIN_EMAIL'): - SMTP_ADMIN_EMAIL = os.getenv('SMTP_ADMIN_EMAIL') -else: - SMTP_ADMIN_EMAIL = SET_SMTP_ADMIN_EMAIL - -if os.getenv('LDAP_HOST'): - LDAP_HOST = os.getenv('LDAP_HOST') -else: - LDAP_HOST = SET_LDAP_HOST - -if os.getenv('LDAP_PORT'): - LDAP_PORT = os.getenv('LDAP_PORT') -else: - LDAP_PORT = SET_LDAP_PORT - -if os.getenv('LDAP_BASE_DN'): - LDAP_BASE_DN = os.getenv('LDAP_BASE_DN') -else: - LDAP_BASE_DN = SET_LDAP_BASE_DN - -if os.getenv('LDAP_USER_DN'): - LDAP_USER_DN = os.getenv('LDAP_USER_DN') -else: - LDAP_USER_DN = SET_LDAP_USER_DN - -if os.getenv('LDAP_GROUP_DN'): - LDAP_GROUP_DN = os.getenv('LDAP_GROUP_DN') -else: - LDAP_GROUP_DN = SET_LDAP_GROUP_DN - -if os.getenv('LDAP_USER_RDN_ATTR'): - LDAP_USER_RDN_ATTR = os.getenv('LDAP_USER_RDN_ATTR') -else: - LDAP_USER_RDN_ATTR = SET_LDAP_USER_RDN_ATTR - -if os.getenv('LDAP_USER_LOGIN_ATTR'): - LDAP_USER_LOGIN_ATTR = os.getenv('LDAP_USER_LOGIN_ATTR') -else: - LDAP_USER_LOGIN_ATTR = SET_LDAP_USER_LOGIN_ATTR - -if os.getenv('LDAP_BIND_USER_DN'): - LDAP_BIND_USER_DN = os.getenv('LDAP_BIND_USER_DN') -else: - LDAP_BIND_USER_DN = SET_LDAP_BIND_USER_DN - -if os.getenv('LDAP_BIND_USER_PASSWORD'): - LDAP_BIND_USER_PASSWORD = os.getenv('LDAP_BIND_USER_PASSWORD') -else: - LDAP_BIND_USER_PASSWORD = SET_LDAP_BIND_USER_PASSWORD +def getConfigs(config): + config['TEST_SETTING'] = 'set' + + config['VERSION'] = '0.1.0-beta' + + if os.getenv('AZURE_KEYVAULT_NAME'): + config['AZURE_KEYVAULT_NAME'] = os.getenv('AZURE_KEYVAULT_NAME') + else: + config['AZURE_KEYVAULT_NAME'] = SET_AZURE_KEYVAULT_NAME + + if os.getenv('AUTH_TYPE'): + config['AUTH_TYPE'] = os.getenv('AUTH_TYPE') + else: + config['AUTH_TYPE'] = SET_AUTH_TYPE + + if os.getenv('INSECURE_OAUTH'): + config['INSECURE_OAUTH'] = os.getenv('INSECURE_OAUTH') + else: + config['INSECURE_OAUTH'] = SET_INSECURE_OAUTH + + if config['INSECURE_OAUTH']: + os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1' + + if os.getenv('APP_EXT_URL'): + config['APP_EXT_URL'] = os.getenv('APP_EXT_URL') + else: + config['APP_EXT_URL'] = SET_APP_EXT_URL + + if os.getenv('SMTP_HOST'): + config['SMTP_HOST'] = os.getenv('SMTP_HOST') + else: + config['SMTP_HOST'] = SET_SMTP_HOST + + if os.getenv('SMTP_USER'): + config['SMTP_USER'] = os.getenv('SMTP_USER') + else: + config['SMTP_USER'] = SET_SMTP_USER + + if os.getenv('SMTP_ADMIN_EMAIL'): + config['SMTP_ADMIN_EMAIL'] = os.getenv('SMTP_ADMIN_EMAIL') + else: + config['SMTP_ADMIN_EMAIL'] = SET_SMTP_ADMIN_EMAIL + + if os.getenv('LDAP_HOST'): + config['LDAP_HOST'] = os.getenv('LDAP_HOST') + else: + config['LDAP_HOST'] = SET_LDAP_HOST + + if os.getenv('LDAP_PORT'): + config['LDAP_PORT'] = os.getenv('LDAP_PORT') + else: + config['LDAP_PORT'] = SET_LDAP_PORT + + if os.getenv('LDAP_BASE_DN'): + config['LDAP_BASE_DN'] = os.getenv('LDAP_BASE_DN') + else: + config['LDAP_BASE_DN'] = SET_LDAP_BASE_DN + + if os.getenv('LDAP_USER_DN'): + config['LDAP_USER_DN'] = os.getenv('LDAP_USER_DN') + else: + config['LDAP_USER_DN'] = SET_LDAP_USER_DN + + if os.getenv('LDAP_GROUP_DN'): + config['LDAP_GROUP_DN'] = os.getenv('LDAP_GROUP_DN') + else: + config['LDAP_GROUP_DN'] = SET_LDAP_GROUP_DN + + if os.getenv('LDAP_USER_RDN_ATTR'): + config['LDAP_USER_RDN_ATTR'] = os.getenv('LDAP_USER_RDN_ATTR') + else: + config['LDAP_USER_RDN_ATTR'] = SET_LDAP_USER_RDN_ATTR + + if os.getenv('LDAP_USER_LOGIN_ATTR'): + config['LDAP_USER_LOGIN_ATTR'] = os.getenv('LDAP_USER_LOGIN_ATTR') + else: + config['LDAP_USER_LOGIN_ATTR'] = SET_LDAP_USER_LOGIN_ATTR + + if os.getenv('LDAP_BIND_USER_DN'): + config['LDAP_BIND_USER_DN'] = os.getenv('LDAP_BIND_USER_DN') + else: + config['LDAP_BIND_USER_DN'] = SET_LDAP_BIND_USER_DN + + if os.getenv('LDAP_BIND_USER_PASSWORD'): + config['LDAP_BIND_USER_PASSWORD'] = os.getenv('LDAP_BIND_USER_PASSWORD') + else: + config['LDAP_BIND_USER_PASSWORD'] = SET_LDAP_BIND_USER_PASSWORD + + ## CORE Config Variables ## + if os.getenv('ENV'): + config['ENV'] = os.getenv('ENV') + else: + config['ENV'] = SET_ENV + + if config['ENV'] == 'prod': + if os.getenv('PROD_DB_URI_REF'): + config['PROD_DB_URI'] = KeyVaultManager(config).get_secret(os.getenv('PROD_DB_URI_REF')) + else: + config['PROD_DB_URI'] = KeyVaultManager(config).get_secret(SET_PROD_DB_URI_REF) + else: + config['PROD_DB_URI'] = SET_PROD_DB_URI + + if config['AUTH_TYPE'] == 'azuread': + if os.getenv('AZAD_CLIENT_ID'): + config['AZAD_CLIENT_ID'] = os.getenv('AZAD_CLIENT_ID') + else: + config['AZAD_CLIENT_ID'] = SET_AZAD_CLIENT_ID + if os.getenv('AZAD_CLIENT_SECRET'): + config['AZAD_CLIENT_SECRET'] = KeyVaultManager(config).get_secret(os.getenv('AZAD_CLIENT_SECRET')) + else: + config['AZAD_CLIENT_SECRET'] = KeyVaultManager(config).get_secret(SET_AZAD_CLIENT_SECRET) + if os.getenv('AZAD_AUTHORITY'): + config['AZAD_AUTHORITY'] = os.getenv('AZAD_AUTHORITY') + else: + config['AZAD_AUTHORITY'] = SET_AZAD_AUTHORITY + else: + config['AZAD_CLIENT_ID'] = "" + config['AZAD_CLIENT_SECRET'] = "" + config['AZAD_AUTHORITY'] = "" + + ## Email Variables ## + if config['ENV'] == 'prod': + if os.getenv('SMTP_PW_REF'): + config['SMTP_PASSWORD'] = KeyVaultManager(config).get_secret(os.getenv('SMTP_PW_REF')) + else: + config['SMTP_PASSWORD'] = KeyVaultManager(config).get_secret(SET_SMTP_PW_REF) + else: + config['SMTP_PASSWORD'] = SET_SMTP_PW + + ## + ## GitHub to Jenkins Webhook ## + if os.getenv('JENKINS_ENABLED'): + config['JENKINS_ENABLED'] = os.getenv('JENKINS_ENABLED') + else: + config['JENKINS_ENABLED'] = SET_JENKINS_ENABLED + if config['JENKINS_ENABLED'] == 'yes': + if config['ENV'] == 'prod': + if os.getenv('JENKINS_USER'): + config['JENKINS_USER'] = KeyVaultManager(config).get_secret(os.getenv('JENKINS_USER')) + else: + config['JENKINS_USER'] = KeyVaultManager(config).get_secret(SET_JENKINS_USER_REF) + if os.getenv('JENKINS_KEY'): + config['JENKINS_KEY'] = KeyVaultManager(config).get_secret(os.getenv('JENKINS_KEY')) + else: + config['JENKINS_KEY'] = KeyVaultManager(config).get_secret(SET_JENKINS_KEY_REF) + if os.getenv('JENKINS_TOKEN'): + config['JENKINS_TOKEN'] = KeyVaultManager(config).get_secret(os.getenv('JENKINS_TOKEN')) + else: + config['JENKINS_TOKEN'] = KeyVaultManager(config).get_secret(SET_JENKINS_TOKEN_REF) + else: + config['JENKINS_USER'] = SET_JENKINS_USER + config['JENKINS_KEY'] = SET_JENKINS_KEY + config['JENKINS_TOKEN'] = SET_JENKINS_TOKEN + + if os.getenv('JENKINS_PROJECT'): + config['JENKINS_PROJECT'] = os.getenv('JENKINS_PROJECT') + else: + config['JENKINS_PROJECT'] = SET_JENKINS_PROJECT + + if os.getenv('JENKINS_HOST'): + config['JENKINS_HOST'] = os.getenv('JENKINS_HOST') + else: + config['JENKINS_HOST'] = SET_JENKINS_HOST + + if os.getenv('JENKINS_STAGING_PROJECT'): + config['JENKINS_STAGING_PROJECT'] = os.getenv('JENKINS_STAGING_PROJECT') + else: + config['JENKINS_STAGING_PROJECT'] = SET_JENKINS_STAGING_PROJECT + else: + config['JENKINS_USER'] = "" + config['JENKINS_KEY'] = "" + config['JENKINS_TOKEN'] = "" + config['JENKINS_PROJECT'] = "" + config['JENKINS_HOST'] = "" + config['JENKINS_STAGING_PROJECT'] = "" + + ## ServiceNOW Integration + if os.getenv('SNOW_ENABLED'): + config['SNOW_ENABLED'] = os.getenv('SNOW_ENABLED') + else: + config['SNOW_ENABLED'] = SET_SNOW_ENABLED + if config['SNOW_ENABLED'] == 'yes': + if config['ENV'] == 'prod': + if os.getenv('SNOW_PASSWORD'): + config['SNOW_PASSWORD'] = KeyVaultManager(config).get_secret(os.getenv('SNOW_PASSWORD')) + else: + config['SNOW_PASSWORD'] = KeyVaultManager(config).get_secret(SET_SNOW_PASSWORD_REF) + if os.getenv('SNOW_CLIENT_SECRET'): + config['SNOW_CLIENT_SECRET'] = KeyVaultManager(config).get_secret(os.getenv('SNOW_CLIENT_SECRET')) + else: + config['SNOW_CLIENT_SECRET'] = KeyVaultManager(config).get_secret(SET_SNOW_CLIENT_SECRET_REF) + if os.getenv('SNOW_INSTANCE_NAME'): + config['SNOW_INSTANCE_NAME'] = os.getenv('SNOW_INSTANCE_NAME') + else: + config['SNOW_INSTANCE_NAME'] = SET_SNOW_INSTANCE_NAME + if os.getenv('SNOW_CLIENT_ID'): + config['SNOW_CLIENT_ID'] = os.getenv('SNOW_CLIENT_ID') + else: + config['SNOW_CLIENT_ID'] = SET_SNOW_CLIENT_ID + if os.getenv('SNOW_USERNAME'): + config['SNOW_USERNAME'] = os.getenv('SNOW_USERNAME') + else: + config['SNOW_USERNAME'] = SET_SNOW_USERNAME + else: + config['SNOW_PASSWORD'] = SET_SNOW_PASSWORD + config['SNOW_CLIENT_SECRET'] = SET_SNOW_CLIENT_SECRET + config['SNOW_INSTANCE_NAME'] = SET_SNOW_INSTANCE_NAME + config['SNOW_CLIENT_ID'] = SET_SNOW_CLIENT_ID + config['SNOW_USERNAME'] = SET_SNOW_USERNAME + else: + config['SNOW_PASSWORD'] = "" + config['SNOW_CLIENT_SECRET'] = "" + config['SNOW_INSTANCE_NAME'] = "" + config['SNOW_CLIENT_ID'] = "" + config['SNOW_USERNAME'] = "" class KeyVaultManager(object): - def __init__(self): + def __init__(self, config=None): if os.getenv('AZURE_KEYVAULT_NAME'): key_vault_uri = f"https://{os.getenv('AZURE_KEYVAULT_NAME')}.vault.azure.net" else: - key_vault_uri = f"https://{AZURE_KEYVAULT_NAME}.vault.azure.net" + key_vault_uri = f"https://{config['AZURE_KEYVAULT_NAME']}.vault.azure.net" if os.getenv('AZURE_AUTH_METHOD'): if os.getenv('AZURE_AUTH_METHOD') == 'env': self.credential = EnvironmentCredential( @@ -162,130 +293,3 @@ def delete_cert(self, secret_name): return deleted_secret -## CORE Config Variables ## -if os.getenv('ENV'): - ENV = os.getenv('ENV') -else: - ENV = SET_ENV - -if ENV == 'prod': - if os.getenv('PROD_DB_URI_REF'): - PROD_DB_URI = KeyVaultManager().get_secret(os.getenv('PROD_DB_URI_REF')) - else: - PROD_DB_URI = KeyVaultManager().get_secret(SET_PROD_DB_URI_REF) -else: - PROD_DB_URI = SET_PROD_DB_URI - -if AUTH_TYPE == 'azuread': - if os.getenv('AZAD_CLIENT_ID'): - AZAD_CLIENT_ID = os.getenv('AZAD_CLIENT_ID') - else: - AZAD_CLIENT_ID = SET_AZAD_CLIENT_ID - if os.getenv('AZAD_CLIENT_SECRET'): - AZAD_CLIENT_SECRET = KeyVaultManager().get_secret(os.getenv('AZAD_CLIENT_SECRET')) - else: - AZAD_CLIENT_SECRET = KeyVaultManager().get_secret(SET_AZAD_CLIENT_SECRET) - if os.getenv('AZAD_AUTHORITY'): - AZAD_AUTHORITY = os.getenv('AZAD_AUTHORITY') - else: - AZAD_AUTHORITY = SET_AZAD_AUTHORITY -else: - AZAD_CLIENT_ID = "" - AZAD_CLIENT_SECRET = "" - AZAD_AUTHORITY = "" - -## Email Variables ## -if ENV == 'prod': - if os.getenv('SMTP_PW_REF'): - SMTP_PASSWORD = KeyVaultManager().get_secret(os.getenv('SMTP_PW_REF')) - else: - SMTP_PASSWORD = KeyVaultManager().get_secret(SET_SMTP_PW_REF) -else: - SMTP_PASSWORD = SET_SMTP_PW - -## -## GitHub to Jenkins Webhook ## -if os.getenv('JENKINS_ENABLED'): - JENKINS_ENABLED = os.getenv('JENKINS_ENABLED') -else: - JENKINS_ENABLED = SET_JENKINS_ENABLED -if JENKINS_ENABLED == 'yes': - if ENV == 'prod': - if os.getenv('JENKINS_USER'): - JENKINS_USER = KeyVaultManager().get_secret(os.getenv('JENKINS_USER')) - else: - JENKINS_USER = KeyVaultManager().get_secret(SET_JENKINS_USER_REF) - if os.getenv('JENKINS_KEY'): - JENKINS_KEY = KeyVaultManager().get_secret(os.getenv('JENKINS_KEY')) - else: - JENKINS_KEY = KeyVaultManager().get_secret(SET_JENKINS_KEY_REF) - if os.getenv('JENKINS_TOKEN'): - JENKINS_TOKEN = KeyVaultManager().get_secret(os.getenv('JENKINS_TOKEN')) - else: - JENKINS_TOKEN = KeyVaultManager().get_secret(SET_JENKINS_TOKEN_REF) - else: - JENKINS_USER = SET_JENKINS_USER - JENKINS_KEY = SET_JENKINS_KEY - JENKINS_TOKEN = SET_JENKINS_TOKEN - - if os.getenv('JENKINS_PROJECT'): - JENKINS_PROJECT = os.getenv('JENKINS_PROJECT') - else: - JENKINS_PROJECT = SET_JENKINS_PROJECT - - if os.getenv('JENKINS_HOST'): - JENKINS_HOST = os.getenv('JENKINS_HOST') - else: - JENKINS_HOST = SET_JENKINS_HOST - - if os.getenv('JENKINS_STAGING_PROJECT'): - JENKINS_STAGING_PROJECT = os.getenv('JENKINS_STAGING_PROJECT') - else: - JENKINS_STAGING_PROJECT = SET_JENKINS_STAGING_PROJECT -else: - JENKINS_USER = "" - JENKINS_KEY = "" - JENKINS_TOKEN = "" - JENKINS_PROJECT = "" - JENKINS_HOST = "" - JENKINS_STAGING_PROJECT = "" - -## ServiceNOW Integration -if os.getenv('SNOW_ENABLED'): - SNOW_ENABLED = os.getenv('SNOW_ENABLED') -else: - SNOW_ENABLED = SET_SNOW_ENABLED -if SNOW_ENABLED == 'yes': - if ENV == 'prod': - if os.getenv('SNOW_PASSWORD'): - SNOW_PASSWORD = KeyVaultManager().get_secret(os.getenv('SNOW_PASSWORD')) - else: - SNOW_PASSWORD = KeyVaultManager().get_secret(SET_SNOW_PASSWORD_REF) - if os.getenv('SNOW_CLIENT_SECRET'): - SNOW_CLIENT_SECRET = KeyVaultManager().get_secret(os.getenv('SNOW_CLIENT_SECRET')) - else: - SNOW_CLIENT_SECRET = KeyVaultManager().get_secret(SET_SNOW_CLIENT_SECRET_REF) - if os.getenv('SNOW_INSTANCE_NAME'): - SNOW_INSTANCE_NAME = os.getenv('SNOW_INSTANCE_NAME') - else: - SNOW_INSTANCE_NAME = SET_SNOW_INSTANCE_NAME - if os.getenv('SNOW_CLIENT_ID'): - SNOW_CLIENT_ID = os.getenv('SNOW_CLIENT_ID') - else: - SNOW_CLIENT_ID = SET_SNOW_CLIENT_ID - if os.getenv('SNOW_USERNAME'): - SNOW_USERNAME = os.getenv('SNOW_USERNAME') - else: - SNOW_USERNAME = SET_SNOW_USERNAME - else: - SNOW_PASSWORD = SET_SNOW_PASSWORD - SNOW_CLIENT_SECRET = SET_SNOW_CLIENT_SECRET - SNOW_INSTANCE_NAME = SET_SNOW_INSTANCE_NAME - SNOW_CLIENT_ID = SET_SNOW_CLIENT_ID - SNOW_USERNAME = SET_SNOW_USERNAME -else: - SNOW_PASSWORD = "" - SNOW_CLIENT_SECRET = "" - SNOW_INSTANCE_NAME = "" - SNOW_CLIENT_ID = "" - SNOW_USERNAME = "" diff --git a/src/run.py b/src/run.py index 7f0f15c7..b67be678 100644 --- a/src/run.py +++ b/src/run.py @@ -4,10 +4,9 @@ import datetime import os from vr.admin.oauth2 import config_oauth -from config_engine import ENV, INSECURE_OAUTH -if ENV == 'test' or INSECURE_OAUTH: +if app.config['ENV'] == 'test' or app.config['INSECURE_OAUTH']: os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1' else: os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '0' diff --git a/src/vr/__init__.py b/src/vr/__init__.py index 42a86ea1..2f3ccf73 100644 --- a/src/vr/__init__.py +++ b/src/vr/__init__.py @@ -1,8 +1,6 @@ import datetime import requests -from config_engine import ENV, PROD_DB_URI, AUTH_TYPE, APP_EXT_URL, LDAP_HOST, LDAP_PORT, LDAP_BASE_DN, \ - LDAP_USER_DN, LDAP_GROUP_DN, LDAP_USER_RDN_ATTR, LDAP_USER_LOGIN_ATTR, LDAP_BIND_USER_DN, LDAP_BIND_USER_PASSWORD, \ - AZAD_CLIENT_ID, AZAD_CLIENT_SECRET, AZAD_AUTHORITY, JENKINS_USER, JENKINS_ENABLED +from config_engine import getConfigs from flask import Flask from flask_bootstrap import Bootstrap from flask_login import LoginManager @@ -11,8 +9,7 @@ from flask_wtf.csrf import CSRFProtect from flaskext.markdown import Markdown from vr.db_models.setup import _init_db -if AUTH_TYPE == 'ldap': - from flask_ldap3_login import LDAP3LoginManager + import base64 import logging import sys @@ -31,48 +28,41 @@ from requests.auth import HTTPBasicAuth from vr.db_models.updates import createNewTables -if AUTH_TYPE == 'azuread': + +app = Flask(__name__) + +getConfigs(app.config) + +if app.config['AUTH_TYPE'] == 'azuread': from flask_session import Session import msal from flask import session, url_for +if app.config['AUTH_TYPE'] == 'ldap': + from flask_ldap3_login import LDAP3LoginManager -app = Flask(__name__) moment = Moment(app) Markdown(app) csrf = CSRFProtect(app) -app.config['APP_EXT_URL'] = APP_EXT_URL - -app.config['RUNTIME_ENV'] = ENV +app.config['RUNTIME_ENV'] = app.config['ENV'] if app.config['RUNTIME_ENV'] == 'test': DB_URI = 'sqlite:///database.db' import sqlite3 else: - DB_URI = PROD_DB_URI + DB_URI = app.config['PROD_DB_URI'] import mysql.connector app.config['SQLALCHEMY_DATABASE_URI'] = DB_URI app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False -if AUTH_TYPE == 'ldap': - # LDAP Configuration - app.config['LDAP_HOST'] = LDAP_HOST - app.config['LDAP_PORT'] = LDAP_PORT - app.config['LDAP_BASE_DN'] = LDAP_BASE_DN - app.config['LDAP_USER_DN'] = LDAP_USER_DN - app.config['LDAP_GROUP_DN'] = LDAP_GROUP_DN - app.config['LDAP_USER_RDN_ATTR'] = LDAP_USER_RDN_ATTR - app.config['LDAP_USER_LOGIN_ATTR'] = LDAP_USER_LOGIN_ATTR - app.config['LDAP_BIND_USER_DN'] = LDAP_BIND_USER_DN - app.config['LDAP_BIND_USER_PASSWORD'] = LDAP_BIND_USER_PASSWORD - +if app.config['AUTH_TYPE'] == 'ldap': # Flask-LDAP3-Login Manager ldap_manager = LDAP3LoginManager(app) -elif AUTH_TYPE == 'azuread': - app.config['CLIENT_ID'] = AZAD_CLIENT_ID - app.config['CLIENT_SECRET'] = AZAD_CLIENT_SECRET - app.config['AUTHORITY'] = AZAD_AUTHORITY +elif app.config['AUTH_TYPE'] == 'azuread': + app.config['CLIENT_ID'] = app.config['AZAD_CLIENT_ID'] + app.config['CLIENT_SECRET'] = app.config['AZAD_CLIENT_SECRET'] + app.config['AUTHORITY'] = app.config['AZAD_AUTHORITY'] app.config['REDIRECT_PATH'] = "/getAToken" app.config['ENDPOINT'] = 'https://graph.microsoft.com/v1.0/me/memberOf' app.config['SCOPE'] = ["User.ReadBasic.All", "Group.Read.All", "Application.Read.All"] @@ -151,7 +141,7 @@ def _get_token_from_cache(scope=None): app.register_blueprint(api) bootstrap = Bootstrap(app) -if AUTH_TYPE == 'local' or AUTH_TYPE == 'azuread': +if app.config['AUTH_TYPE'] == 'local' or app.config['AUTH_TYPE'] == 'azuread': login_manager.init_app(app) login_manager.login_view = 'admin.login' @@ -162,9 +152,10 @@ def _get_token_from_cache(scope=None): app.logger.addHandler(stdout_handler) + @app.template_filter('format_datetime') def format_datetime(value): - if ENV == 'test': + if app.config['ENV'] == 'test': try: formatted = datetime.datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f") except: @@ -185,6 +176,8 @@ def base64encode(value): createNewTables(app) ## Cronjob-like tasks section ## + + def train_model_every_six_hours(): scheduler = BackgroundScheduler() scheduler.add_job(train_model, 'interval', hours=6) @@ -220,6 +213,53 @@ def connect_to_db(): cur = db.cursor() return cur, db +def getPersistentConfig(): + try: + cur, db = connect_to_db() + sql = 'SELECT * FROM AppConfig WHERE 1=1' + cur.execute(sql) + row = cur.fetchone() + if row[2]: + app.config['APP_EXT_URL'] = row[3] + app.config['AUTH_TYPE'] = row[4] + app.config['AZAD_AUTHORITY'] = row[5] + app.config['AZAD_CLIENT_ID'] = row[6] + app.config['AZAD_CLIENT_SECRET'] = row[7] + app.config['AZURE_KEYVAULT_NAME'] = row[8] + app.config['ENV'] = row[9] + app.config['INSECURE_OAUTH'] = row[10] + app.config['JENKINS_ENABLED'] = row[37] + app.config['JENKINS_HOST'] = row[11] + app.config['JENKINS_KEY'] = row[12] + app.config['JENKINS_PROJECT'] = row[13] + app.config['JENKINS_STAGING_PROJECT'] = row[14] + app.config['JENKINS_TOKEN'] = row[15] + app.config['JENKINS_USER'] = row[16] + app.config['LDAP_BASE_DN'] = row[17] + app.config['LDAP_BIND_USER_DN'] = row[18] + app.config['LDAP_BIND_USER_PASSWORD'] = row[19] + app.config['LDAP_GROUP_DN'] = row[20] + app.config['LDAP_HOST'] = row[21] + app.config['LDAP_PORT'] = row[22] + app.config['LDAP_USER_DN'] = row[23] + app.config['LDAP_USER_LOGIN_ATTR'] = row[24] + app.config['LDAP_USER_RDN_ATTR'] = row[25] + app.config['PROD_DB_URI'] = row[26] + app.config['SMTP_ADMIN_EMAIL'] = row[27] + app.config['SMTP_HOST'] = row[28] + app.config['SMTP_PASSWORD'] = row[29] + app.config['SMTP_USER'] = row[30] + app.config['SNOW_ENABLED'] = row[38] + app.config['SNOW_CLIENT_ID'] = row[31] + app.config['SNOW_CLIENT_SECRET'] = row[32] + app.config['SNOW_INSTANCE_NAME'] = row[33] + app.config['SNOW_PASSWORD'] = row[34] + app.config['SNOW_USERNAME'] = row[35] + app.config['VERSION'] = row[36] + except: + print('AppConfig Database table is either unreachable or not setup.') + +getPersistentConfig() def train_model(): try: @@ -337,7 +377,7 @@ def rsa_long_decrypt(priv_obj, msg, length=256): def get_jenkins_data(): - user_check = JENKINS_USER + user_check = app.config['JENKINS_USER'] if user_check != 'changeme': app.logger.info('Getting Jenkins Data') cur, db = connect_to_db() @@ -452,5 +492,5 @@ def get_jenkins_data(): # Call the Jobs Here # train_model_every_six_hours() -if JENKINS_ENABLED == 'yes': +if app.config['JENKINS_ENABLED'] == 'yes': get_jenkins_data_every_hour() diff --git a/src/vr/admin/auth_functions.py b/src/vr/admin/auth_functions.py index 20ddf7ca..885020c6 100644 --- a/src/vr/admin/auth_functions.py +++ b/src/vr/admin/auth_functions.py @@ -1,7 +1,7 @@ import jwt from time import time from vr.functions.mysql_db import connect_to_db -from config_engine import ENV +from vr import app # Error handler @@ -49,7 +49,7 @@ def create_api_key(user_id, otp_secret, expires_in=2592000): def verify_api_key(token): try: cur, db = connect_to_db() - if ENV == 'test': + if app.config['ENV'] == 'test': sql = 'SELECT oc.user_id, u.is_admin FROM oauth2_client oc JOIN oauth2_token ot ON oc.client_id=ot.client_id JOIN User u ON oc.user_id=u.id WHERE ot.id=?' else: sql = 'SELECT oc.user_id, u.is_admin FROM oauth2_client oc JOIN oauth2_token ot ON oc.client_id=ot.client_id JOIN User u ON oc.user_id=u.id WHERE ot.id=%s' diff --git a/src/vr/admin/email_alerts.py b/src/vr/admin/email_alerts.py index a1c48da3..698b5138 100644 --- a/src/vr/admin/email_alerts.py +++ b/src/vr/admin/email_alerts.py @@ -1,7 +1,7 @@ import smtplib from email.mime import multipart from email.mime import text as mimetext -from config_engine import SMTP_HOST, SMTP_USER, SMTP_PASSWORD, SMTP_ADMIN_EMAIL +from vr import app def send_email(msg_fromaddr, msg_toaddr, msg_subject, msg_body): @@ -11,9 +11,9 @@ def send_email(msg_fromaddr, msg_toaddr, msg_subject, msg_body): msg['To'] = msg_toaddr msg['Subject'] = msg_subject msg.attach(mimetext.MIMEText(message, 'html')) - server = smtplib.SMTP(SMTP_HOST) + server = smtplib.SMTP(app.config['SMTP_HOST']) server.starttls() - server.login(SMTP_USER, SMTP_PASSWORD) + server.login(app.config['SMTP_USER'], app.config['SMTP_PASSWORD']) server.ehlo() text = msg.as_string() server.sendmail(msg_fromaddr, msg_toaddr, text) @@ -24,7 +24,7 @@ def send_registration_email(ext_url, username, first_name, last_name, token, ema msg_subject = "SecuSphere User Registration" msg_body = generate_registration_msg(ext_url, username, first_name, last_name, token) try: - send_email(SMTP_ADMIN_EMAIL, email_to, msg_subject, msg_body) + send_email(app.config['SMTP_ADMIN_EMAIL'], email_to, msg_subject, msg_body) except: return 'error' diff --git a/src/vr/admin/models.py b/src/vr/admin/models.py index 89785772..d5d5e4ad 100644 --- a/src/vr/admin/models.py +++ b/src/vr/admin/models.py @@ -3,7 +3,7 @@ from flask_login import UserMixin from vr import db, app from vr.functions.mysql_db import connect_to_db -from datetime import datetime, timedelta +from datetime import datetime import jwt from vr.admin.helper_functions import hash_password,verify_password from vr.admin.functions import db_connection_handler @@ -17,8 +17,7 @@ OAuth2AuthorizationCodeMixin, OAuth2TokenMixin, ) -from config_engine import AUTH_TYPE -if AUTH_TYPE == 'ldap': +if app.config['AUTH_TYPE'] == 'ldap': from vr import ldap_manager if app.config['RUNTIME_ENV'] == 'test': @@ -190,11 +189,11 @@ def verify_username_token(self, token, given_id): else: return -if AUTH_TYPE == 'local' or AUTH_TYPE == 'azuread': +if app.config['AUTH_TYPE'] == 'local' or app.config['AUTH_TYPE'] == 'azuread': @login_manager.user_loader def load_user(id): return User.query.get(int(id)) -elif AUTH_TYPE == 'ldap': +elif app.config['AUTH_TYPE'] == 'ldap': # User Loader for LDAP @login_manager.user_loader def load_user(user_id): diff --git a/src/vr/admin/routes/forgotpw.py b/src/vr/admin/routes/forgotpw.py index 2d12cd59..f6d50228 100644 --- a/src/vr/admin/routes/forgotpw.py +++ b/src/vr/admin/routes/forgotpw.py @@ -6,7 +6,6 @@ from vr.admin.email_alerts import send_email, generate_evnt_msg from vr.functions.timefunctions import return_datetime_now from vr.admin.helper_functions import hash_password -from config_engine import SMTP_ADMIN_EMAIL from vr.admin.functions import db_connection_handler @@ -32,7 +31,7 @@ def forgotpw(): action_list = [action] st = 'n' msg_body = generate_evnt_msg(msg_subject, now, evt_list, action_list, st) - msg_fromaddr = SMTP_ADMIN_EMAIL + msg_fromaddr = app.config['SMTP_ADMIN_EMAIL'] try: send_email(msg_fromaddr, email, msg_subject, msg_body) warnmsg = ('pwresetemail', 'success') diff --git a/src/vr/admin/routes/forgotun.py b/src/vr/admin/routes/forgotun.py index 80c52425..d8a0d2fa 100644 --- a/src/vr/admin/routes/forgotun.py +++ b/src/vr/admin/routes/forgotun.py @@ -5,7 +5,6 @@ from vr.admin.models import User, LoginForm from vr.admin.email_alerts import send_email, generate_evnt_msg from vr.functions.timefunctions import return_datetime_now -from config_engine import SMTP_ADMIN_EMAIL NAV_CAT= { "name": "Admin", "url": "admin.admin_dashboard"} @@ -28,7 +27,7 @@ def forgotun(): action_list = [action] st = 'n' msg_body = generate_evnt_msg(msg_subject,now,evt_list,action_list,st) - msg_fromaddr = SMTP_ADMIN_EMAIL + msg_fromaddr = app.config['SMTP_ADMIN_EMAIL'] try: send_email(msg_fromaddr, email, msg_subject, msg_body) warnmsg = ('pwresetemail', 'success') diff --git a/src/vr/admin/routes/login.py b/src/vr/admin/routes/login.py index 9eed58a7..d7f641f1 100644 --- a/src/vr/admin/routes/login.py +++ b/src/vr/admin/routes/login.py @@ -8,10 +8,9 @@ from vr.admin.models import User, LoginForm, AuthAttempts, AppConfig from vr.admin.functions import _auth_user, _entity_permissions_filter, _entity_page_permissions_filter, check_lockout, log_failed_attempt from vr.admin.functions import db_connection_handler -from config_engine import AUTH_TYPE -if AUTH_TYPE == 'ldap': +if app.config['AUTH_TYPE'] == 'ldap': from flask_ldap3_login.forms import LDAPLoginForm -elif AUTH_TYPE == 'azuread': +elif app.config['AUTH_TYPE'] == 'azuread': import requests import msal from vr import _build_auth_code_flow, _load_cache, _save_cache, _build_msal_app, _get_token_from_cache @@ -35,7 +34,7 @@ def login(): return redirect(url_for('admin.register')) ad_auth_url = None warnmsg = '' - if AUTH_TYPE == 'local': + if app.config['AUTH_TYPE'] == 'local': if current_user.is_authenticated: flash('You are already logged in.', 'danger') return redirect(url_for('assets.all_applications')) @@ -60,7 +59,7 @@ def login(): mfa_password = resp[2] # attempt to log the user in return _login_attempt(user, username, password, userid, form, mfa_password) - elif AUTH_TYPE == 'ldap': + elif app.config['AUTH_TYPE'] == 'ldap': form = LDAPLoginForm() if form.validate_on_submit(): # Log the user in @@ -71,15 +70,15 @@ def login(): # Print the form errors print("Form validation failed with errors:", form.errors) return render_template(LDAP_LOGIN_TEMPLATE, form=form, errors=form.errors) - elif AUTH_TYPE == 'azuread': + elif app.config['AUTH_TYPE'] == 'azuread': form = LoginForm(request.form) session["flow"] = _build_auth_code_flow(scopes=app.config['SCOPE']) ad_auth_url = session["flow"]["auth_uri"] if form.errors: warnmsg = (form.errors, 'danger') - return render_template(LOGIN_TEMPLATE, form=form, warnmsg=warnmsg, auth_type=AUTH_TYPE, auth_url=ad_auth_url) + return render_template(LOGIN_TEMPLATE, form=form, warnmsg=warnmsg, auth_type=app.config['AUTH_TYPE'], auth_url=ad_auth_url) -if AUTH_TYPE == 'azuread': +if app.config['AUTH_TYPE'] == 'azuread': @app.route(app.config['REDIRECT_PATH']) # Its absolute URL must match your app's redirect_uri set in AAD def authorized(): try: diff --git a/src/vr/admin/routes/logout.py b/src/vr/admin/routes/logout.py index 218cd357..781302c9 100644 --- a/src/vr/admin/routes/logout.py +++ b/src/vr/admin/routes/logout.py @@ -1,20 +1,20 @@ from flask_login import logout_user, login_required from flask import session, redirect, url_for from vr.admin import admin -from config_engine import AUTH_TYPE +from vr import app NAV_CAT= { "name": "Admin", "url": "admin.admin_dashboard"} -if AUTH_TYPE == 'local': +if app.config['AUTH_TYPE'] == 'local': @admin.route('/logout') @login_required def logout(): logout_user() del session['username'] return redirect(url_for('admin.login')) -elif AUTH_TYPE == 'azuread': +elif app.config['AUTH_TYPE'] == 'azuread': @admin.route('/logout') def logout(): logout_user() diff --git a/src/vr/admin/routes/register.py b/src/vr/admin/routes/register.py index 38f0b3f8..1f6f38a8 100644 --- a/src/vr/admin/routes/register.py +++ b/src/vr/admin/routes/register.py @@ -13,7 +13,6 @@ from vr.admin.helper_functions import hash_password from vr.admin.email_alerts import send_registration_email from vr.functions.initial_setup import setup_core_db_tables, generate_key_pair -from config_engine import ENV from vr.db_models.setup_2 import _init_db @@ -115,7 +114,7 @@ def register_submit(): _init_db(db=db) generate_key_pair() - setup_core_db_tables(ENV) + setup_core_db_tables(app.config['ENV']) admin_role = UserRoles.query.filter_by(name='Admin').first() ura = UserRoleAssignments(user_id=user.id, role_id=admin_role.id) db.session.add(ura) diff --git a/src/vr/admin/routes/settings.py b/src/vr/admin/routes/settings.py index fea3e3b5..532ae0d5 100644 --- a/src/vr/admin/routes/settings.py +++ b/src/vr/admin/routes/settings.py @@ -5,16 +5,8 @@ # Start of Entity-specific Imports from vr.admin import admin from vr.admin.functions import _auth_user, check_menu_tour_init -from config_engine import ENV, PROD_DB_URI, AUTH_TYPE, APP_EXT_URL, LDAP_HOST, LDAP_PORT, LDAP_BASE_DN, \ - LDAP_USER_DN, LDAP_GROUP_DN, LDAP_USER_RDN_ATTR, LDAP_USER_LOGIN_ATTR, LDAP_BIND_USER_DN, LDAP_BIND_USER_PASSWORD, \ - AZAD_CLIENT_ID, AZAD_CLIENT_SECRET, AZAD_AUTHORITY, JENKINS_USER, AZURE_KEYVAULT_NAME, INSECURE_OAUTH, \ - JENKINS_HOST, JENKINS_KEY, JENKINS_PROJECT, JENKINS_STAGING_PROJECT, JENKINS_TOKEN, SMTP_ADMIN_EMAIL, \ - SMTP_HOST, SMTP_PASSWORD, SMTP_USER, SNOW_CLIENT_ID, SNOW_CLIENT_SECRET, SNOW_INSTANCE_NAME, SNOW_PASSWORD, \ - SNOW_USERNAME, VERSION, JENKINS_ENABLED, SNOW_ENABLED -from flask_sqlalchemy import SQLAlchemy from vr.admin.models import AppConfig from vr.admin.functions import db_connection_handler -from sqlalchemy import text NAV = { @@ -44,7 +36,7 @@ def settings(): AppConfig.AZAD_CLIENT_ID: all["AZAD_CLIENT_ID"], AppConfig.AZAD_CLIENT_SECRET: all["AZAD_CLIENT_SECRET"], AppConfig.AZURE_KEYVAULT_NAME: all["AZURE_KEYVAULT_NAME"], - AppConfig.ENV: ENV, + AppConfig.ENV: app.config['ENV'], AppConfig.INSECURE_OAUTH: all["INSECURE_OAUTH"], AppConfig.JENKINS_HOST: all["JENKINS_HOST"], AppConfig.JENKINS_KEY: all["JENKINS_KEY"], @@ -71,7 +63,7 @@ def settings(): AppConfig.SNOW_INSTANCE_NAME: all["SNOW_INSTANCE_NAME"], AppConfig.SNOW_PASSWORD: all["SNOW_PASSWORD"], AppConfig.SNOW_USERNAME: all["SNOW_USERNAME"], - AppConfig.VERSION: VERSION, + AppConfig.VERSION: app.config['VERSION'], } if not app_config.settings_initialized: update_json[AppConfig.settings_initialized] = True @@ -88,7 +80,7 @@ def settings(): "AZAD_CLIENT_ID": all["AZAD_CLIENT_ID"], "AZAD_CLIENT_SECRET": all["AZAD_CLIENT_SECRET"], "AZURE_KEYVAULT_NAME": all["AZURE_KEYVAULT_NAME"], - "ENV": ENV, + "ENV": app.config['ENV'], "INSECURE_OAUTH": all["INSECURE_OAUTH"], "JENKINS_HOST": all["JENKINS_HOST"], "JENKINS_KEY": all["JENKINS_KEY"], @@ -115,7 +107,7 @@ def settings(): "SNOW_INSTANCE_NAME": all["SNOW_INSTANCE_NAME"], "SNOW_PASSWORD": all["SNOW_PASSWORD"], "SNOW_USERNAME": all["SNOW_USERNAME"], - "VERSION": VERSION, + "VERSION": app.config['VERSION'], } else: app_config = AppConfig.query.first() @@ -160,42 +152,42 @@ def settings(): } else: current_settings = { - "JENKINS_ENABLED": JENKINS_ENABLED, - "SNOW_ENABLED": SNOW_ENABLED, - "APP_EXT_URL": APP_EXT_URL, - "AUTH_TYPE": AUTH_TYPE, - "AZAD_AUTHORITY":AZAD_AUTHORITY, - "AZAD_CLIENT_ID": AZAD_CLIENT_ID, - "AZAD_CLIENT_SECRET": AZAD_CLIENT_SECRET, - "AZURE_KEYVAULT_NAME": AZURE_KEYVAULT_NAME, - "ENV": ENV, - "INSECURE_OAUTH": INSECURE_OAUTH, - "JENKINS_HOST": JENKINS_HOST, - "JENKINS_KEY": JENKINS_KEY, - "JENKINS_PROJECT": JENKINS_PROJECT, - "JENKINS_STAGING_PROJECT": JENKINS_STAGING_PROJECT, - "JENKINS_USER": JENKINS_USER, - "JENKINS_TOKEN": JENKINS_TOKEN, - "LDAP_BASE_DN": LDAP_BASE_DN, - "LDAP_BIND_USER_DN": LDAP_BIND_USER_DN, - "LDAP_BIND_USER_PASSWORD": LDAP_BIND_USER_PASSWORD, - "LDAP_GROUP_DN": LDAP_GROUP_DN, - "LDAP_HOST": LDAP_HOST, - "LDAP_PORT": LDAP_PORT, - "LDAP_USER_DN": LDAP_USER_DN, - "LDAP_USER_LOGIN_ATTR": LDAP_USER_LOGIN_ATTR, - "LDAP_USER_RDN_ATTR": LDAP_USER_RDN_ATTR, - "PROD_DB_URI": PROD_DB_URI, - "SMTP_ADMIN_EMAIL": SMTP_ADMIN_EMAIL, - "SMTP_HOST": SMTP_HOST, - "SMTP_USER": SMTP_USER, - "SMTP_PASSWORD": SMTP_PASSWORD, - "SNOW_CLIENT_ID": SNOW_CLIENT_ID, - "SNOW_CLIENT_SECRET": SNOW_CLIENT_SECRET, - "SNOW_INSTANCE_NAME": SNOW_INSTANCE_NAME, - "SNOW_USERNAME": SNOW_USERNAME, - "SNOW_PASSWORD": SNOW_PASSWORD, - "VERSION": VERSION, + "JENKINS_ENABLED": app.config['JENKINS_ENABLED'], + "SNOW_ENABLED": app.config['SNOW_ENABLED'], + "APP_EXT_URL": app.config['APP_EXT_URL'], + "AUTH_TYPE": app.config['AUTH_TYPE'], + "AZAD_AUTHORITY": app.config['AZAD_AUTHORITY'], + "AZAD_CLIENT_ID": app.config['AZAD_CLIENT_ID'], + "AZAD_CLIENT_SECRET": app.config['AZAD_CLIENT_SECRET'], + "AZURE_KEYVAULT_NAME": app.config['AZURE_KEYVAULT_NAME'], + "ENV": app.config['ENV'], + "INSECURE_OAUTH": app.config['INSECURE_OAUTH'], + "JENKINS_HOST": app.config['JENKINS_HOST'], + "JENKINS_KEY": app.config['JENKINS_KEY'], + "JENKINS_PROJECT": app.config['JENKINS_PROJECT'], + "JENKINS_STAGING_PROJECT": app.config['JENKINS_STAGING_PROJECT'], + "JENKINS_USER": app.config['JENKINS_USER'], + "JENKINS_TOKEN": app.config['JENKINS_TOKEN'], + "LDAP_BASE_DN": app.config['LDAP_BASE_DN'], + "LDAP_BIND_USER_DN": app.config['LDAP_BIND_USER_DN'], + "LDAP_BIND_USER_PASSWORD": app.config['LDAP_BIND_USER_PASSWORD'], + "LDAP_GROUP_DN": app.config['LDAP_GROUP_DN'], + "LDAP_HOST": app.config['LDAP_HOST'], + "LDAP_PORT": app.config['LDAP_PORT'], + "LDAP_USER_DN": app.config['LDAP_USER_DN'], + "LDAP_USER_LOGIN_ATTR": app.config['LDAP_USER_LOGIN_ATTR'], + "LDAP_USER_RDN_ATTR": app.config['LDAP_USER_RDN_ATTR'], + "PROD_DB_URI": app.config['PROD_DB_URI'], + "SMTP_ADMIN_EMAIL": app.config['SMTP_ADMIN_EMAIL'], + "SMTP_HOST": app.config['SMTP_HOST'], + "SMTP_USER": app.config['SMTP_USER'], + "SMTP_PASSWORD": app.config['SMTP_PASSWORD'], + "SNOW_CLIENT_ID": app.config['SNOW_CLIENT_ID'], + "SNOW_CLIENT_SECRET": app.config['SNOW_CLIENT_SECRET'], + "SNOW_INSTANCE_NAME": app.config['SNOW_INSTANCE_NAME'], + "SNOW_USERNAME": app.config['SNOW_USERNAME'], + "SNOW_PASSWORD": app.config['SNOW_PASSWORD'], + "VERSION": app.config['VERSION'], } cat_general = [ 'APP_EXT_URL', @@ -257,7 +249,7 @@ def set_env_variables(form): os.environ['AZAD_CLIENT_ID'] = form["AZAD_CLIENT_ID"] os.environ['AZAD_CLIENT_SECRET'] = form["AZAD_CLIENT_SECRET"] os.environ['AZURE_KEYVAULT_NAME'] = form["AZURE_KEYVAULT_NAME"] - os.environ['ENV'] = ENV + os.environ['ENV'] = app.config['ENV'] os.environ['INSECURE_OAUTH'] = form["INSECURE_OAUTH"] os.environ['JENKINS_ENABLED'] = form["JENKINS_ENABLED"] os.environ['JENKINS_HOST'] = form["JENKINS_HOST"] @@ -286,7 +278,43 @@ def set_env_variables(form): os.environ['SNOW_INSTANCE_NAME'] = form["SNOW_INSTANCE_NAME"] os.environ['SNOW_PASSWORD'] = form["SNOW_PASSWORD"] os.environ['SNOW_USERNAME'] = form["SNOW_USERNAME"] - os.environ['VERSION'] = VERSION + os.environ['VERSION'] = app.config['VERSION'] + app.config['APP_EXT_URL'] = form["APP_EXT_URL"] + app.config['AUTH_TYPE'] = form["AUTH_TYPE"] + app.config['AZAD_AUTHORITY'] = form["AZAD_AUTHORITY"] + app.config['AZAD_CLIENT_ID'] = form["AZAD_CLIENT_ID"] + app.config['AZAD_CLIENT_SECRET'] = form["AZAD_CLIENT_SECRET"] + app.config['AZURE_KEYVAULT_NAME'] = form["AZURE_KEYVAULT_NAME"] + app.config['ENV'] = app.config['ENV'] + app.config['INSECURE_OAUTH'] = form["INSECURE_OAUTH"] + app.config['JENKINS_ENABLED'] = form["JENKINS_ENABLED"] + app.config['JENKINS_HOST'] = form["JENKINS_HOST"] + app.config['JENKINS_KEY'] = form["JENKINS_KEY"] + app.config['JENKINS_PROJECT'] = form["JENKINS_PROJECT"] + app.config['JENKINS_STAGING_PROJECT'] = form["JENKINS_STAGING_PROJECT"] + app.config['JENKINS_TOKEN'] = form["JENKINS_TOKEN"] + app.config['JENKINS_USER'] = form["JENKINS_USER"] + app.config['LDAP_BASE_DN'] = form["LDAP_BASE_DN"] + app.config['LDAP_BIND_USER_DN'] = form["LDAP_BIND_USER_DN"] + app.config['LDAP_BIND_USER_PASSWORD'] = form["LDAP_BIND_USER_PASSWORD"] + app.config['LDAP_GROUP_DN'] = form["LDAP_GROUP_DN"] + app.config['LDAP_HOST'] = form["LDAP_HOST"] + app.config['LDAP_PORT'] = form["LDAP_PORT"] + app.config['LDAP_USER_DN'] = form["LDAP_USER_DN"] + app.config['LDAP_USER_LOGIN_ATTR'] = form["LDAP_USER_LOGIN_ATTR"] + app.config['LDAP_USER_RDN_ATTR'] = form["LDAP_USER_RDN_ATTR"] + app.config['PROD_DB_URI'] = form["PROD_DB_URI"] + app.config['SMTP_ADMIN_EMAIL'] = form["SMTP_ADMIN_EMAIL"] + app.config['SMTP_HOST'] = form["SMTP_HOST"] + app.config['SMTP_PASSWORD'] = form["SMTP_PASSWORD"] + app.config['SMTP_USER'] = form["SMTP_USER"] + app.config['SNOW_ENABLED'] = form["SNOW_ENABLED"] + app.config['SNOW_CLIENT_ID'] = form["SNOW_CLIENT_ID"] + app.config['SNOW_CLIENT_SECRET'] = form["SNOW_CLIENT_SECRET"] + app.config['SNOW_INSTANCE_NAME'] = form["SNOW_INSTANCE_NAME"] + app.config['SNOW_PASSWORD'] = form["SNOW_PASSWORD"] + app.config['SNOW_USERNAME'] = form["SNOW_USERNAME"] + app.config['VERSION'] = app.config['VERSION'] @admin.route('/dangerous/delete_all', methods=['POST']) @@ -300,7 +328,7 @@ def delete_all_data(): nav_subsubcat='', nav_curpage={"name": "Unauthorized"}) try: - if ENV == 'test': + if app.config['ENV'] == 'test': # Ensure all connections to the database are closed db.session.close() db.engine.dispose() diff --git a/src/vr/admin/routes/users.py b/src/vr/admin/routes/users.py index 5e461b33..95f12ae3 100644 --- a/src/vr/admin/routes/users.py +++ b/src/vr/admin/routes/users.py @@ -8,7 +8,6 @@ from sqlalchemy import text from flask import request, render_template, session, redirect, url_for, json from flask_login import login_required -from config_engine import AUTH_TYPE from vr.functions.table_functions import load_table, update_table from vr.admin.email_alerts import send_registration_email from vr.assets.model.businessapplications import BusinessApplications @@ -296,7 +295,7 @@ def add_new_user(): first_name=firstname, last_name=lastname, is_active=False, - auth_type=AUTH_TYPE, + auth_type=app.config['AUTH_TYPE'], otp_secret=otp_secret, user_type='system', avatar_path='/static/images/default_profile_avatar.jpg' diff --git a/src/vr/api/integrations/servicenow.py b/src/vr/api/integrations/servicenow.py index 5f76555a..ec06d99f 100644 --- a/src/vr/api/integrations/servicenow.py +++ b/src/vr/api/integrations/servicenow.py @@ -1,13 +1,12 @@ from flask import jsonify, request import requests import json +from vr import app from vr.api import api from vr.admin.oauth2 import require_oauth from authlib.integrations.flask_oauth2 import current_token from vr.admin.auth_functions import verify_api_key, get_token_auth_header from vr.functions.routing_functions import check_entity_permissions -from vr.assets.model.applicationprofiles import ApplicationProfiles, ApplicationProfilesSchema -from config_engine import SNOW_PASSWORD, SNOW_CLIENT_SECRET, SNOW_INSTANCE_NAME, SNOW_CLIENT_ID, SNOW_USERNAME ERROR_RESP = "Error: Invalid API Request" @@ -184,11 +183,11 @@ def create_new_collaboration_tools(snow_obj, app_name, app_desc): return sys_id_map # ServiceNow instance details -INSTANCE_NAME = SNOW_INSTANCE_NAME -CLIENT_ID = SNOW_CLIENT_ID -CLIENT_SECRET = SNOW_CLIENT_SECRET -USERNAME = SNOW_USERNAME -PASSWORD = SNOW_PASSWORD +INSTANCE_NAME = app.config['SNOW_INSTANCE_NAME'] +CLIENT_ID = app.config['SNOW_CLIENT_ID'] +CLIENT_SECRET = app.config['SNOW_CLIENT_SECRET'] +USERNAME = app.config['SNOW_USERNAME'] +PASSWORD = app.config['SNOW_PASSWORD'] TOKEN_URL = f'https://{INSTANCE_NAME}.service-now.com/oauth_token.do' TOKEN_DATA = { diff --git a/src/vr/api/vulns/jenkins_webhook.py b/src/vr/api/vulns/jenkins_webhook.py index 28f1824e..0b2e8b2d 100644 --- a/src/vr/api/vulns/jenkins_webhook.py +++ b/src/vr/api/vulns/jenkins_webhook.py @@ -2,10 +2,11 @@ import datetime from threading import Thread from flask import jsonify, request, json -from vr import db +from vr import db, app from vr.api import api from requests.auth import HTTPBasicAuth -from config_engine import JENKINS_USER, JENKINS_KEY, JENKINS_PROJECT, JENKINS_HOST, JENKINS_TOKEN +# from config_engine import JENKINS_USER, JENKINS_KEY, JENKINS_PROJECT, JENKINS_HOST, JENKINS_TOKEN +from config_engine import getConfigs from vr.admin.oauth2 import require_oauth from sqlalchemy import text from vr.assets.model.cicdpipelinebuilds import CICDPipelineBuilds @@ -25,6 +26,7 @@ @api.route('/api/jenkins_webhook', methods=['POST']) @require_oauth('write:vulnerabilities') def jenkins_webhook(): + getConfigs(app.config) all = request.form payload_dict = json.loads(all['payload']) ref = payload_dict['ref'] diff --git a/src/vr/api/vulns/vulnerabilities.py b/src/vr/api/vulns/vulnerabilities.py index 68360c8b..b151f5bf 100644 --- a/src/vr/api/vulns/vulnerabilities.py +++ b/src/vr/api/vulns/vulnerabilities.py @@ -16,7 +16,6 @@ from vr.admin.oauth2 import require_oauth from vr.admin.functions import db_connection_handler from authlib.integrations.flask_oauth2 import current_token -from config_engine import ENV import re @@ -295,7 +294,7 @@ def _add_new_vulns(new_vulns, engine): def _setup_duplicate_vulns(source_type, dup_vulns): sourced_dup_vulns = [] for vuln in dup_vulns: - if ENV == 'test': + if app.config['ENV'] == 'test': vuln['LastModifiedDate'] = datetime.datetime.utcnow().replace(microsecond=0) if vuln['ReleaseDate']: vuln['ReleaseDate'] = datetime.datetime.strptime(vuln['ReleaseDate'], '%Y-%m-%d %H:%M:%S') diff --git a/src/vr/db_models/setup.py b/src/vr/db_models/setup.py index b36fdc22..cb37b344 100644 --- a/src/vr/db_models/setup.py +++ b/src/vr/db_models/setup.py @@ -1,11 +1,6 @@ from datetime import datetime from sqlalchemy.types import TEXT, DECIMAL from flask import jsonify -from config_engine import ENV -if ENV == 'test': - from sqlalchemy.dialects.sqlite import TEXT as LONGTEXT -else: - from sqlalchemy.dialects.mysql import LONGTEXT from flask_sqlalchemy import SQLAlchemy from sqlalchemy.dialects import mysql from flask_login import UserMixin @@ -176,9 +171,9 @@ class TmControls(db.Model): __tablename__ = 'TmControls' ID = db.Column(db.Integer, primary_key=True) AddDate = db.Column(db.DateTime, index=True, default=datetime.utcnow, nullable=False) - Control = db.Column(LONGTEXT) + Control = db.Column(db.String(20000)) Type = db.Column(db.String(8)) - Description = db.Column(LONGTEXT) + Description = db.Column(db.String(20000)) Lambda = db.Column(db.String(1)) Process = db.Column(db.String(1)) Server = db.Column(db.String(1)) diff --git a/src/vr/db_models/setup_2.py b/src/vr/db_models/setup_2.py index d47ba210..0d98c122 100644 --- a/src/vr/db_models/setup_2.py +++ b/src/vr/db_models/setup_2.py @@ -2,8 +2,8 @@ from sqlalchemy.types import TEXT, DECIMAL from sqlalchemy import MetaData from vr.admin.functions import db_connection_handler -from config_engine import ENV -if ENV == 'test': +from vr import app +if app.config['ENV'] == 'test': from sqlalchemy.dialects.sqlite import TEXT as LONGTEXT else: from sqlalchemy.dialects.mysql import LONGTEXT diff --git a/src/vr/orchestration/web/pipeline_jobs.py b/src/vr/orchestration/web/pipeline_jobs.py index e9fcc7ee..2ef5390b 100644 --- a/src/vr/orchestration/web/pipeline_jobs.py +++ b/src/vr/orchestration/web/pipeline_jobs.py @@ -11,7 +11,6 @@ from vr.orchestration.model.cicdpipelines import CICDPipelines, CICDPipelinesSchema from vr.orchestration.model.pipelinejobs import PipelineJobs, PipelineJobsSchema from vr.orchestration.web.pipeline_stage_data import OPTS -from config_engine import JENKINS_USER, JENKINS_KEY, JENKINS_STAGING_PROJECT, JENKINS_HOST, JENKINS_TOKEN NAV = { @@ -248,7 +247,7 @@ def validate_cicd_pipeline_stage(appid): "Content-Type": "application/x-www-form-urlencoded" } data = { - 'token': JENKINS_TOKEN, + 'token': app.config['JENKINS_TOKEN'], 'GIT_URL': git_url, 'GIT_BRANCH': git_branch, 'APP_NAME': app_name, @@ -261,8 +260,8 @@ def validate_cicd_pipeline_stage(appid): 'TARGET_URL': target_url } - url = f'{JENKINS_HOST}/job/{JENKINS_STAGING_PROJECT}/buildWithParameters' - resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(JENKINS_USER, JENKINS_KEY)) + url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_STAGING_PROJECT']}/buildWithParameters" + resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) return str(200) diff --git a/src/vr/templates/admin/settings.html b/src/vr/templates/admin/settings.html index a7564e1a..f5da3318 100644 --- a/src/vr/templates/admin/settings.html +++ b/src/vr/templates/admin/settings.html @@ -134,7 +134,7 @@

General Settings

{% elif key == "PROD_DB_URI" %} -
+
{% elif key == "ENV" or key == "VERSION" %} {% else %} @@ -176,7 +176,7 @@

SMTP Settings

{% if key == 'SMTP_PASSWORD' %} -
+
{% else %} {% endif %} @@ -199,10 +199,10 @@

Jenkins Settings

{% elif key == 'JENKINS_KEY' %} -
+
{% elif key == 'JENKINS_TOKEN' %} -
+
{% else %} @@ -229,10 +229,10 @@

ServiceNOW Settings

{% elif key == 'SNOW_CLIENT_SECRET' %} -
+
{% elif key == 'SNOW_PASSWORD' %} -
+
{% else %} diff --git a/src/vr/vulns/web/findings.py b/src/vr/vulns/web/findings.py index 8c9938c8..06d44322 100644 --- a/src/vr/vulns/web/findings.py +++ b/src/vr/vulns/web/findings.py @@ -25,7 +25,6 @@ import base64 from io import StringIO from flask import Response -from config_engine import ENV from vr.functions.ml_functions import predict_vuln_validity from vr.vulns.model.cvssbasescoresv3 import CVSSBaseScoresV3 from vr.vulns.model.cvssbasescoresv3extensions import CVSSBaseScoresV3Extensions @@ -42,7 +41,7 @@ UNAUTH_STATUS = "403.html" SERVER_ERR_STATUS = "500.html" VULN_STATUS_IS_NOT_CLOSED = "Vulnerabilities.Status NOT LIKE 'Closed-%' AND Vulnerabilities.Status NOT LIKE 'Open-RiskAccepted-%'" -test = ENV +test = app.config['ENV'] if test == 'test': ISO_FORMAT = "%Y-%m-%dT%H:%M:%S.%f" else: diff --git a/src/vr/vulns/web/testing.py b/src/vr/vulns/web/testing.py index 32e604b8..c69f7122 100644 --- a/src/vr/vulns/web/testing.py +++ b/src/vr/vulns/web/testing.py @@ -11,8 +11,8 @@ from vr.vulns.model.vulnerabilityscans import VulnerabilityScans, VulnerabilityScansSchema from vr.functions.table_functions import load_table, update_table from requests.auth import HTTPBasicAuth -from config_engine import JENKINS_USER, JENKINS_KEY, JENKINS_PROJECT, JENKINS_HOST, JENKINS_TOKEN from vr.assets.model.applicationprofiles import ApplicationProfiles, ApplicationProfilesSchema +from vr import app NAV = { @@ -115,14 +115,14 @@ def on_demand_testing(): "Content-Type": "application/x-www-form-urlencoded" } data = { - 'token': JENKINS_TOKEN, + 'token': app.config['JENKINS_TOKEN'], 'GIT_URL': git_url, 'TESTS': tests_to_run.upper(), 'GIT_BRANCH': git_branch, 'APP_NAME': app_name } - url = f'{JENKINS_HOST}/job/{JENKINS_PROJECT}/buildWithParameters' - resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(JENKINS_USER, JENKINS_KEY)) + url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" + resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) return redirect(request.referrer) From ba8b3dc8fed4570fc4e9877a3cfae8a5e4260632 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 07:58:31 -0700 Subject: [PATCH 078/197] Update pipeline-config.yaml --- pipeline-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline-config.yaml b/pipeline-config.yaml index 2a9eb073..d19730b0 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -9,7 +9,7 @@ stages: branches: - release unitTesting: - enabled: false + enabled: true branches: [] secretScanning: enabled: false From 9edb485f6d54f026937b347d8069aa844047bf7f Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 08:04:28 -0700 Subject: [PATCH 079/197] Feature/jenkins updates (#519) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml --- pipeline-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline-config.yaml b/pipeline-config.yaml index 2a9eb073..d19730b0 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -9,7 +9,7 @@ stages: branches: - release unitTesting: - enabled: false + enabled: true branches: [] secretScanning: enabled: false From c58a7474a1d466043fe3ab3fc68fcfacf4ffbe2d Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 08:04:54 -0700 Subject: [PATCH 080/197] Release/0.1.0 beta/prod azure (#520) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile * Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * Feature/update settings function (#501) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * Feature/update release based db settings (#503) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * Feature/update release based db settings (#505) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#507) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#509) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Feature/fix syntax error (#511) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Feature/fix syntax error (#513) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Feature/fix syntax error (#515) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * Feature/fix syntax error (#517) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Feature/jenkins updates (#519) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml --- pipeline-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline-config.yaml b/pipeline-config.yaml index 2a9eb073..d19730b0 100644 --- a/pipeline-config.yaml +++ b/pipeline-config.yaml @@ -9,7 +9,7 @@ stages: branches: - release unitTesting: - enabled: false + enabled: true branches: [] secretScanning: enabled: false From 42f91fddcc01ba9cb8c2be4fe8bd6ef1cdd8549a Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 10:30:49 -0700 Subject: [PATCH 081/197] Update __init__.py --- src/vr/__init__.py | 85 ++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/src/vr/__init__.py b/src/vr/__init__.py index 2f3ccf73..90fe1b09 100644 --- a/src/vr/__init__.py +++ b/src/vr/__init__.py @@ -214,50 +214,47 @@ def connect_to_db(): return cur, db def getPersistentConfig(): - try: - cur, db = connect_to_db() - sql = 'SELECT * FROM AppConfig WHERE 1=1' - cur.execute(sql) - row = cur.fetchone() - if row[2]: - app.config['APP_EXT_URL'] = row[3] - app.config['AUTH_TYPE'] = row[4] - app.config['AZAD_AUTHORITY'] = row[5] - app.config['AZAD_CLIENT_ID'] = row[6] - app.config['AZAD_CLIENT_SECRET'] = row[7] - app.config['AZURE_KEYVAULT_NAME'] = row[8] - app.config['ENV'] = row[9] - app.config['INSECURE_OAUTH'] = row[10] - app.config['JENKINS_ENABLED'] = row[37] - app.config['JENKINS_HOST'] = row[11] - app.config['JENKINS_KEY'] = row[12] - app.config['JENKINS_PROJECT'] = row[13] - app.config['JENKINS_STAGING_PROJECT'] = row[14] - app.config['JENKINS_TOKEN'] = row[15] - app.config['JENKINS_USER'] = row[16] - app.config['LDAP_BASE_DN'] = row[17] - app.config['LDAP_BIND_USER_DN'] = row[18] - app.config['LDAP_BIND_USER_PASSWORD'] = row[19] - app.config['LDAP_GROUP_DN'] = row[20] - app.config['LDAP_HOST'] = row[21] - app.config['LDAP_PORT'] = row[22] - app.config['LDAP_USER_DN'] = row[23] - app.config['LDAP_USER_LOGIN_ATTR'] = row[24] - app.config['LDAP_USER_RDN_ATTR'] = row[25] - app.config['PROD_DB_URI'] = row[26] - app.config['SMTP_ADMIN_EMAIL'] = row[27] - app.config['SMTP_HOST'] = row[28] - app.config['SMTP_PASSWORD'] = row[29] - app.config['SMTP_USER'] = row[30] - app.config['SNOW_ENABLED'] = row[38] - app.config['SNOW_CLIENT_ID'] = row[31] - app.config['SNOW_CLIENT_SECRET'] = row[32] - app.config['SNOW_INSTANCE_NAME'] = row[33] - app.config['SNOW_PASSWORD'] = row[34] - app.config['SNOW_USERNAME'] = row[35] - app.config['VERSION'] = row[36] - except: - print('AppConfig Database table is either unreachable or not setup.') + cur, db = connect_to_db() + sql = 'SELECT * FROM AppConfig WHERE 1=1' + cur.execute(sql) + row = cur.fetchone() + if row[2]: + app.config['APP_EXT_URL'] = row[3] + app.config['AUTH_TYPE'] = row[4] + app.config['AZAD_AUTHORITY'] = row[5] + app.config['AZAD_CLIENT_ID'] = row[6] + app.config['AZAD_CLIENT_SECRET'] = row[7] + app.config['AZURE_KEYVAULT_NAME'] = row[8] + app.config['ENV'] = row[9] + app.config['INSECURE_OAUTH'] = row[10] + app.config['JENKINS_ENABLED'] = row[37] + app.config['JENKINS_HOST'] = row[11] + app.config['JENKINS_KEY'] = row[12] + app.config['JENKINS_PROJECT'] = row[13] + app.config['JENKINS_STAGING_PROJECT'] = row[14] + app.config['JENKINS_TOKEN'] = row[15] + app.config['JENKINS_USER'] = row[16] + app.config['LDAP_BASE_DN'] = row[17] + app.config['LDAP_BIND_USER_DN'] = row[18] + app.config['LDAP_BIND_USER_PASSWORD'] = row[19] + app.config['LDAP_GROUP_DN'] = row[20] + app.config['LDAP_HOST'] = row[21] + app.config['LDAP_PORT'] = row[22] + app.config['LDAP_USER_DN'] = row[23] + app.config['LDAP_USER_LOGIN_ATTR'] = row[24] + app.config['LDAP_USER_RDN_ATTR'] = row[25] + app.config['PROD_DB_URI'] = row[26] + app.config['SMTP_ADMIN_EMAIL'] = row[27] + app.config['SMTP_HOST'] = row[28] + app.config['SMTP_PASSWORD'] = row[29] + app.config['SMTP_USER'] = row[30] + app.config['SNOW_ENABLED'] = row[38] + app.config['SNOW_CLIENT_ID'] = row[31] + app.config['SNOW_CLIENT_SECRET'] = row[32] + app.config['SNOW_INSTANCE_NAME'] = row[33] + app.config['SNOW_PASSWORD'] = row[34] + app.config['SNOW_USERNAME'] = row[35] + app.config['VERSION'] = row[36] getPersistentConfig() From 76926b35975dcf8330a2d17ec2bc87fec6fa4605 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 10:37:27 -0700 Subject: [PATCH 082/197] Feature/jenkins updates (#521) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py --- src/vr/__init__.py | 85 ++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/src/vr/__init__.py b/src/vr/__init__.py index 2f3ccf73..90fe1b09 100644 --- a/src/vr/__init__.py +++ b/src/vr/__init__.py @@ -214,50 +214,47 @@ def connect_to_db(): return cur, db def getPersistentConfig(): - try: - cur, db = connect_to_db() - sql = 'SELECT * FROM AppConfig WHERE 1=1' - cur.execute(sql) - row = cur.fetchone() - if row[2]: - app.config['APP_EXT_URL'] = row[3] - app.config['AUTH_TYPE'] = row[4] - app.config['AZAD_AUTHORITY'] = row[5] - app.config['AZAD_CLIENT_ID'] = row[6] - app.config['AZAD_CLIENT_SECRET'] = row[7] - app.config['AZURE_KEYVAULT_NAME'] = row[8] - app.config['ENV'] = row[9] - app.config['INSECURE_OAUTH'] = row[10] - app.config['JENKINS_ENABLED'] = row[37] - app.config['JENKINS_HOST'] = row[11] - app.config['JENKINS_KEY'] = row[12] - app.config['JENKINS_PROJECT'] = row[13] - app.config['JENKINS_STAGING_PROJECT'] = row[14] - app.config['JENKINS_TOKEN'] = row[15] - app.config['JENKINS_USER'] = row[16] - app.config['LDAP_BASE_DN'] = row[17] - app.config['LDAP_BIND_USER_DN'] = row[18] - app.config['LDAP_BIND_USER_PASSWORD'] = row[19] - app.config['LDAP_GROUP_DN'] = row[20] - app.config['LDAP_HOST'] = row[21] - app.config['LDAP_PORT'] = row[22] - app.config['LDAP_USER_DN'] = row[23] - app.config['LDAP_USER_LOGIN_ATTR'] = row[24] - app.config['LDAP_USER_RDN_ATTR'] = row[25] - app.config['PROD_DB_URI'] = row[26] - app.config['SMTP_ADMIN_EMAIL'] = row[27] - app.config['SMTP_HOST'] = row[28] - app.config['SMTP_PASSWORD'] = row[29] - app.config['SMTP_USER'] = row[30] - app.config['SNOW_ENABLED'] = row[38] - app.config['SNOW_CLIENT_ID'] = row[31] - app.config['SNOW_CLIENT_SECRET'] = row[32] - app.config['SNOW_INSTANCE_NAME'] = row[33] - app.config['SNOW_PASSWORD'] = row[34] - app.config['SNOW_USERNAME'] = row[35] - app.config['VERSION'] = row[36] - except: - print('AppConfig Database table is either unreachable or not setup.') + cur, db = connect_to_db() + sql = 'SELECT * FROM AppConfig WHERE 1=1' + cur.execute(sql) + row = cur.fetchone() + if row[2]: + app.config['APP_EXT_URL'] = row[3] + app.config['AUTH_TYPE'] = row[4] + app.config['AZAD_AUTHORITY'] = row[5] + app.config['AZAD_CLIENT_ID'] = row[6] + app.config['AZAD_CLIENT_SECRET'] = row[7] + app.config['AZURE_KEYVAULT_NAME'] = row[8] + app.config['ENV'] = row[9] + app.config['INSECURE_OAUTH'] = row[10] + app.config['JENKINS_ENABLED'] = row[37] + app.config['JENKINS_HOST'] = row[11] + app.config['JENKINS_KEY'] = row[12] + app.config['JENKINS_PROJECT'] = row[13] + app.config['JENKINS_STAGING_PROJECT'] = row[14] + app.config['JENKINS_TOKEN'] = row[15] + app.config['JENKINS_USER'] = row[16] + app.config['LDAP_BASE_DN'] = row[17] + app.config['LDAP_BIND_USER_DN'] = row[18] + app.config['LDAP_BIND_USER_PASSWORD'] = row[19] + app.config['LDAP_GROUP_DN'] = row[20] + app.config['LDAP_HOST'] = row[21] + app.config['LDAP_PORT'] = row[22] + app.config['LDAP_USER_DN'] = row[23] + app.config['LDAP_USER_LOGIN_ATTR'] = row[24] + app.config['LDAP_USER_RDN_ATTR'] = row[25] + app.config['PROD_DB_URI'] = row[26] + app.config['SMTP_ADMIN_EMAIL'] = row[27] + app.config['SMTP_HOST'] = row[28] + app.config['SMTP_PASSWORD'] = row[29] + app.config['SMTP_USER'] = row[30] + app.config['SNOW_ENABLED'] = row[38] + app.config['SNOW_CLIENT_ID'] = row[31] + app.config['SNOW_CLIENT_SECRET'] = row[32] + app.config['SNOW_INSTANCE_NAME'] = row[33] + app.config['SNOW_PASSWORD'] = row[34] + app.config['SNOW_USERNAME'] = row[35] + app.config['VERSION'] = row[36] getPersistentConfig() From 626a225ce24f5f8230894059174b22693027f48e Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 10:38:31 -0700 Subject: [PATCH 083/197] Release/0.1.0 beta/prod azure (#522) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile * Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * Feature/update settings function (#501) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * Feature/update release based db settings (#503) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * Feature/update release based db settings (#505) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#507) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#509) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Feature/fix syntax error (#511) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Feature/fix syntax error (#513) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Feature/fix syntax error (#515) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * Feature/fix syntax error (#517) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Feature/jenkins updates (#519) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Feature/jenkins updates (#521) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py --- src/vr/__init__.py | 85 ++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/src/vr/__init__.py b/src/vr/__init__.py index 2f3ccf73..90fe1b09 100644 --- a/src/vr/__init__.py +++ b/src/vr/__init__.py @@ -214,50 +214,47 @@ def connect_to_db(): return cur, db def getPersistentConfig(): - try: - cur, db = connect_to_db() - sql = 'SELECT * FROM AppConfig WHERE 1=1' - cur.execute(sql) - row = cur.fetchone() - if row[2]: - app.config['APP_EXT_URL'] = row[3] - app.config['AUTH_TYPE'] = row[4] - app.config['AZAD_AUTHORITY'] = row[5] - app.config['AZAD_CLIENT_ID'] = row[6] - app.config['AZAD_CLIENT_SECRET'] = row[7] - app.config['AZURE_KEYVAULT_NAME'] = row[8] - app.config['ENV'] = row[9] - app.config['INSECURE_OAUTH'] = row[10] - app.config['JENKINS_ENABLED'] = row[37] - app.config['JENKINS_HOST'] = row[11] - app.config['JENKINS_KEY'] = row[12] - app.config['JENKINS_PROJECT'] = row[13] - app.config['JENKINS_STAGING_PROJECT'] = row[14] - app.config['JENKINS_TOKEN'] = row[15] - app.config['JENKINS_USER'] = row[16] - app.config['LDAP_BASE_DN'] = row[17] - app.config['LDAP_BIND_USER_DN'] = row[18] - app.config['LDAP_BIND_USER_PASSWORD'] = row[19] - app.config['LDAP_GROUP_DN'] = row[20] - app.config['LDAP_HOST'] = row[21] - app.config['LDAP_PORT'] = row[22] - app.config['LDAP_USER_DN'] = row[23] - app.config['LDAP_USER_LOGIN_ATTR'] = row[24] - app.config['LDAP_USER_RDN_ATTR'] = row[25] - app.config['PROD_DB_URI'] = row[26] - app.config['SMTP_ADMIN_EMAIL'] = row[27] - app.config['SMTP_HOST'] = row[28] - app.config['SMTP_PASSWORD'] = row[29] - app.config['SMTP_USER'] = row[30] - app.config['SNOW_ENABLED'] = row[38] - app.config['SNOW_CLIENT_ID'] = row[31] - app.config['SNOW_CLIENT_SECRET'] = row[32] - app.config['SNOW_INSTANCE_NAME'] = row[33] - app.config['SNOW_PASSWORD'] = row[34] - app.config['SNOW_USERNAME'] = row[35] - app.config['VERSION'] = row[36] - except: - print('AppConfig Database table is either unreachable or not setup.') + cur, db = connect_to_db() + sql = 'SELECT * FROM AppConfig WHERE 1=1' + cur.execute(sql) + row = cur.fetchone() + if row[2]: + app.config['APP_EXT_URL'] = row[3] + app.config['AUTH_TYPE'] = row[4] + app.config['AZAD_AUTHORITY'] = row[5] + app.config['AZAD_CLIENT_ID'] = row[6] + app.config['AZAD_CLIENT_SECRET'] = row[7] + app.config['AZURE_KEYVAULT_NAME'] = row[8] + app.config['ENV'] = row[9] + app.config['INSECURE_OAUTH'] = row[10] + app.config['JENKINS_ENABLED'] = row[37] + app.config['JENKINS_HOST'] = row[11] + app.config['JENKINS_KEY'] = row[12] + app.config['JENKINS_PROJECT'] = row[13] + app.config['JENKINS_STAGING_PROJECT'] = row[14] + app.config['JENKINS_TOKEN'] = row[15] + app.config['JENKINS_USER'] = row[16] + app.config['LDAP_BASE_DN'] = row[17] + app.config['LDAP_BIND_USER_DN'] = row[18] + app.config['LDAP_BIND_USER_PASSWORD'] = row[19] + app.config['LDAP_GROUP_DN'] = row[20] + app.config['LDAP_HOST'] = row[21] + app.config['LDAP_PORT'] = row[22] + app.config['LDAP_USER_DN'] = row[23] + app.config['LDAP_USER_LOGIN_ATTR'] = row[24] + app.config['LDAP_USER_RDN_ATTR'] = row[25] + app.config['PROD_DB_URI'] = row[26] + app.config['SMTP_ADMIN_EMAIL'] = row[27] + app.config['SMTP_HOST'] = row[28] + app.config['SMTP_PASSWORD'] = row[29] + app.config['SMTP_USER'] = row[30] + app.config['SNOW_ENABLED'] = row[38] + app.config['SNOW_CLIENT_ID'] = row[31] + app.config['SNOW_CLIENT_SECRET'] = row[32] + app.config['SNOW_INSTANCE_NAME'] = row[33] + app.config['SNOW_PASSWORD'] = row[34] + app.config['SNOW_USERNAME'] = row[35] + app.config['VERSION'] = row[36] getPersistentConfig() From 89ec1bae8abd87053f176526a1b7e07a73dabbab Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 11:12:34 -0700 Subject: [PATCH 084/197] Update __init__.py --- src/vr/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vr/__init__.py b/src/vr/__init__.py index 90fe1b09..e184511e 100644 --- a/src/vr/__init__.py +++ b/src/vr/__init__.py @@ -218,7 +218,7 @@ def getPersistentConfig(): sql = 'SELECT * FROM AppConfig WHERE 1=1' cur.execute(sql) row = cur.fetchone() - if row[2]: + if row and row[2]: app.config['APP_EXT_URL'] = row[3] app.config['AUTH_TYPE'] = row[4] app.config['AZAD_AUTHORITY'] = row[5] From 7dd90fa11418004ade7ff847c0665f491aa17906 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 11:19:14 -0700 Subject: [PATCH 085/197] Feature/jenkins updates (#523) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py --- src/vr/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vr/__init__.py b/src/vr/__init__.py index 90fe1b09..e184511e 100644 --- a/src/vr/__init__.py +++ b/src/vr/__init__.py @@ -218,7 +218,7 @@ def getPersistentConfig(): sql = 'SELECT * FROM AppConfig WHERE 1=1' cur.execute(sql) row = cur.fetchone() - if row[2]: + if row and row[2]: app.config['APP_EXT_URL'] = row[3] app.config['AUTH_TYPE'] = row[4] app.config['AZAD_AUTHORITY'] = row[5] From ff3b6970df0f0b0ed3bdd5b01b8e1dbb726e8c87 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 11:20:06 -0700 Subject: [PATCH 086/197] Release/0.1.0 beta/prod azure (#524) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile * Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * Feature/update settings function (#501) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * Feature/update release based db settings (#503) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * Feature/update release based db settings (#505) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#507) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#509) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Feature/fix syntax error (#511) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Feature/fix syntax error (#513) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Feature/fix syntax error (#515) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * Feature/fix syntax error (#517) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Feature/jenkins updates (#519) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Feature/jenkins updates (#521) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Feature/jenkins updates (#523) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py --- src/vr/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vr/__init__.py b/src/vr/__init__.py index 90fe1b09..e184511e 100644 --- a/src/vr/__init__.py +++ b/src/vr/__init__.py @@ -218,7 +218,7 @@ def getPersistentConfig(): sql = 'SELECT * FROM AppConfig WHERE 1=1' cur.execute(sql) row = cur.fetchone() - if row[2]: + if row and row[2]: app.config['APP_EXT_URL'] = row[3] app.config['AUTH_TYPE'] = row[4] app.config['AZAD_AUTHORITY'] = row[5] From 9f3a6d2a4b60d8629c1a5612e6f8fc67ae246a12 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 11:58:20 -0700 Subject: [PATCH 087/197] Update jenkins_webhook.py --- src/vr/api/vulns/jenkins_webhook.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vr/api/vulns/jenkins_webhook.py b/src/vr/api/vulns/jenkins_webhook.py index 0b2e8b2d..f5698ae3 100644 --- a/src/vr/api/vulns/jenkins_webhook.py +++ b/src/vr/api/vulns/jenkins_webhook.py @@ -219,14 +219,14 @@ def add_new_scan(git_url, branch_name, report_id): "Content-Type": "application/x-www-form-urlencoded" } data = { - 'token': JENKINS_TOKEN, + 'token': app.config['JENKINS_TOKEN'], 'GIT_URL': git_url, 'TESTS': stage_str, 'GIT_BRANCH': branch_name, 'REPORT_ID': report_id } - url = f'{JENKINS_HOST}/job/{JENKINS_PROJECT}/buildWithParameters' - resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(JENKINS_USER, JENKINS_KEY)) + url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" + resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) response = jsonify({"Status": resp.status_code}), 200 except requests.exceptions.Timeout: print('Processing Error') From 3422a4fbc0aa6d05356c0add3ba0215a1f7bce38 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:04:13 -0700 Subject: [PATCH 088/197] Feature/jenkins updates (#525) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py --- src/vr/api/vulns/jenkins_webhook.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vr/api/vulns/jenkins_webhook.py b/src/vr/api/vulns/jenkins_webhook.py index 0b2e8b2d..f5698ae3 100644 --- a/src/vr/api/vulns/jenkins_webhook.py +++ b/src/vr/api/vulns/jenkins_webhook.py @@ -219,14 +219,14 @@ def add_new_scan(git_url, branch_name, report_id): "Content-Type": "application/x-www-form-urlencoded" } data = { - 'token': JENKINS_TOKEN, + 'token': app.config['JENKINS_TOKEN'], 'GIT_URL': git_url, 'TESTS': stage_str, 'GIT_BRANCH': branch_name, 'REPORT_ID': report_id } - url = f'{JENKINS_HOST}/job/{JENKINS_PROJECT}/buildWithParameters' - resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(JENKINS_USER, JENKINS_KEY)) + url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" + resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) response = jsonify({"Status": resp.status_code}), 200 except requests.exceptions.Timeout: print('Processing Error') From fc0f12b20793afeb6e3047a9d4046c8f8d5de602 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:04:42 -0700 Subject: [PATCH 089/197] Release/0.1.0 beta/prod azure (#526) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile * Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * Feature/update settings function (#501) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * Feature/update release based db settings (#503) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * Feature/update release based db settings (#505) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#507) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#509) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Feature/fix syntax error (#511) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Feature/fix syntax error (#513) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Feature/fix syntax error (#515) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * Feature/fix syntax error (#517) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Feature/jenkins updates (#519) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Feature/jenkins updates (#521) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Feature/jenkins updates (#523) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Feature/jenkins updates (#525) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py --- src/vr/api/vulns/jenkins_webhook.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vr/api/vulns/jenkins_webhook.py b/src/vr/api/vulns/jenkins_webhook.py index 0b2e8b2d..f5698ae3 100644 --- a/src/vr/api/vulns/jenkins_webhook.py +++ b/src/vr/api/vulns/jenkins_webhook.py @@ -219,14 +219,14 @@ def add_new_scan(git_url, branch_name, report_id): "Content-Type": "application/x-www-form-urlencoded" } data = { - 'token': JENKINS_TOKEN, + 'token': app.config['JENKINS_TOKEN'], 'GIT_URL': git_url, 'TESTS': stage_str, 'GIT_BRANCH': branch_name, 'REPORT_ID': report_id } - url = f'{JENKINS_HOST}/job/{JENKINS_PROJECT}/buildWithParameters' - resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(JENKINS_USER, JENKINS_KEY)) + url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" + resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) response = jsonify({"Status": resp.status_code}), 200 except requests.exceptions.Timeout: print('Processing Error') From 68b71893ec0b35924933a7f14c79e0e7459ae4fd Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:11:40 -0700 Subject: [PATCH 090/197] Update jenkins_webhook.py --- src/vr/api/vulns/jenkins_webhook.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vr/api/vulns/jenkins_webhook.py b/src/vr/api/vulns/jenkins_webhook.py index f5698ae3..0e7ca0aa 100644 --- a/src/vr/api/vulns/jenkins_webhook.py +++ b/src/vr/api/vulns/jenkins_webhook.py @@ -227,7 +227,7 @@ def add_new_scan(git_url, branch_name, report_id): } url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) - response = jsonify({"Status": resp.status_code}), 200 + # response = jsonify({"Status": resp.status_code}), 200 except requests.exceptions.Timeout: print('Processing Error') From 07cb6a7147d9ab4e50c2e41bd291114b66e6d875 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:19:19 -0700 Subject: [PATCH 091/197] Feature/jenkins updates (#527) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Update jenkins_webhook.py --- src/vr/api/vulns/jenkins_webhook.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vr/api/vulns/jenkins_webhook.py b/src/vr/api/vulns/jenkins_webhook.py index f5698ae3..0e7ca0aa 100644 --- a/src/vr/api/vulns/jenkins_webhook.py +++ b/src/vr/api/vulns/jenkins_webhook.py @@ -227,7 +227,7 @@ def add_new_scan(git_url, branch_name, report_id): } url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) - response = jsonify({"Status": resp.status_code}), 200 + # response = jsonify({"Status": resp.status_code}), 200 except requests.exceptions.Timeout: print('Processing Error') From a2531bb2426b7811bcef69454148440b052b6d94 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:20:27 -0700 Subject: [PATCH 092/197] Release/0.1.0 beta/prod azure (#528) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile * Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * Feature/update settings function (#501) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * Feature/update release based db settings (#503) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * Feature/update release based db settings (#505) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#507) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#509) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Feature/fix syntax error (#511) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Feature/fix syntax error (#513) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Feature/fix syntax error (#515) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * Feature/fix syntax error (#517) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Feature/jenkins updates (#519) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Feature/jenkins updates (#521) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Feature/jenkins updates (#523) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Feature/jenkins updates (#525) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Feature/jenkins updates (#527) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Update jenkins_webhook.py --- src/vr/api/vulns/jenkins_webhook.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vr/api/vulns/jenkins_webhook.py b/src/vr/api/vulns/jenkins_webhook.py index f5698ae3..0e7ca0aa 100644 --- a/src/vr/api/vulns/jenkins_webhook.py +++ b/src/vr/api/vulns/jenkins_webhook.py @@ -227,7 +227,7 @@ def add_new_scan(git_url, branch_name, report_id): } url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) - response = jsonify({"Status": resp.status_code}), 200 + # response = jsonify({"Status": resp.status_code}), 200 except requests.exceptions.Timeout: print('Processing Error') From 685167e7145fb84729f151311d253651b2630e9f Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 13:01:12 -0700 Subject: [PATCH 093/197] Update jenkins_webhook.py --- src/vr/api/vulns/jenkins_webhook.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/vr/api/vulns/jenkins_webhook.py b/src/vr/api/vulns/jenkins_webhook.py index 0e7ca0aa..f3c40868 100644 --- a/src/vr/api/vulns/jenkins_webhook.py +++ b/src/vr/api/vulns/jenkins_webhook.py @@ -21,6 +21,7 @@ from vr.vulns.model.sgglobalthresholds import SgGlobalThresholds from vr.admin.functions import db_connection_handler import traceback +import time @api.route('/api/jenkins_webhook', methods=['POST']) @@ -46,13 +47,13 @@ def jenkins_webhook(): "Content-Type": "application/x-www-form-urlencoded" } data = { - 'token': JENKINS_TOKEN, + 'token': app.config['JENKINS_TOKEN'], 'GIT_URL': git_url, 'TESTS': tests_to_run.upper(), 'GIT_BRANCH': git_branch } - url = f'{JENKINS_HOST}/job/{JENKINS_PROJECT}/buildWithParameters' - resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(JENKINS_USER, JENKINS_KEY)) + url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" + resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) response = jsonify({"Status": resp.status_code}), 200 else: response = jsonify({"Status": "Not Applicable"}), 200 @@ -227,6 +228,7 @@ def add_new_scan(git_url, branch_name, report_id): } url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) + time.sleep(10) # sleep for 10 seconds to allow time for response # response = jsonify({"Status": resp.status_code}), 200 except requests.exceptions.Timeout: print('Processing Error') From 7319eb2c4bd8f4e919cee517642f8136adedbd43 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 13:09:41 -0700 Subject: [PATCH 094/197] Feature/jenkins updates (#529) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py --- src/vr/api/vulns/jenkins_webhook.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/vr/api/vulns/jenkins_webhook.py b/src/vr/api/vulns/jenkins_webhook.py index 0e7ca0aa..f3c40868 100644 --- a/src/vr/api/vulns/jenkins_webhook.py +++ b/src/vr/api/vulns/jenkins_webhook.py @@ -21,6 +21,7 @@ from vr.vulns.model.sgglobalthresholds import SgGlobalThresholds from vr.admin.functions import db_connection_handler import traceback +import time @api.route('/api/jenkins_webhook', methods=['POST']) @@ -46,13 +47,13 @@ def jenkins_webhook(): "Content-Type": "application/x-www-form-urlencoded" } data = { - 'token': JENKINS_TOKEN, + 'token': app.config['JENKINS_TOKEN'], 'GIT_URL': git_url, 'TESTS': tests_to_run.upper(), 'GIT_BRANCH': git_branch } - url = f'{JENKINS_HOST}/job/{JENKINS_PROJECT}/buildWithParameters' - resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(JENKINS_USER, JENKINS_KEY)) + url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" + resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) response = jsonify({"Status": resp.status_code}), 200 else: response = jsonify({"Status": "Not Applicable"}), 200 @@ -227,6 +228,7 @@ def add_new_scan(git_url, branch_name, report_id): } url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) + time.sleep(10) # sleep for 10 seconds to allow time for response # response = jsonify({"Status": resp.status_code}), 200 except requests.exceptions.Timeout: print('Processing Error') From 098111ccb6e5f9e68c7ad7e75523f8c41358053e Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 13:11:20 -0700 Subject: [PATCH 095/197] Release/0.1.0 beta/prod azure (#530) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile * Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * Feature/update settings function (#501) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * Feature/update release based db settings (#503) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * Feature/update release based db settings (#505) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#507) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#509) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Feature/fix syntax error (#511) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Feature/fix syntax error (#513) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Feature/fix syntax error (#515) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * Feature/fix syntax error (#517) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Feature/jenkins updates (#519) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Feature/jenkins updates (#521) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Feature/jenkins updates (#523) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Feature/jenkins updates (#525) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Feature/jenkins updates (#527) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Feature/jenkins updates (#529) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py --- src/vr/api/vulns/jenkins_webhook.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/vr/api/vulns/jenkins_webhook.py b/src/vr/api/vulns/jenkins_webhook.py index 0e7ca0aa..f3c40868 100644 --- a/src/vr/api/vulns/jenkins_webhook.py +++ b/src/vr/api/vulns/jenkins_webhook.py @@ -21,6 +21,7 @@ from vr.vulns.model.sgglobalthresholds import SgGlobalThresholds from vr.admin.functions import db_connection_handler import traceback +import time @api.route('/api/jenkins_webhook', methods=['POST']) @@ -46,13 +47,13 @@ def jenkins_webhook(): "Content-Type": "application/x-www-form-urlencoded" } data = { - 'token': JENKINS_TOKEN, + 'token': app.config['JENKINS_TOKEN'], 'GIT_URL': git_url, 'TESTS': tests_to_run.upper(), 'GIT_BRANCH': git_branch } - url = f'{JENKINS_HOST}/job/{JENKINS_PROJECT}/buildWithParameters' - resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(JENKINS_USER, JENKINS_KEY)) + url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" + resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) response = jsonify({"Status": resp.status_code}), 200 else: response = jsonify({"Status": "Not Applicable"}), 200 @@ -227,6 +228,7 @@ def add_new_scan(git_url, branch_name, report_id): } url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) + time.sleep(10) # sleep for 10 seconds to allow time for response # response = jsonify({"Status": resp.status_code}), 200 except requests.exceptions.Timeout: print('Processing Error') From 9f243931220ea066c4c50a368e336844e293fc63 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 13:40:52 -0700 Subject: [PATCH 096/197] Update jenkins_webhook.py --- src/vr/api/vulns/jenkins_webhook.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/vr/api/vulns/jenkins_webhook.py b/src/vr/api/vulns/jenkins_webhook.py index f3c40868..2411defe 100644 --- a/src/vr/api/vulns/jenkins_webhook.py +++ b/src/vr/api/vulns/jenkins_webhook.py @@ -21,7 +21,7 @@ from vr.vulns.model.sgglobalthresholds import SgGlobalThresholds from vr.admin.functions import db_connection_handler import traceback -import time +import logging @api.route('/api/jenkins_webhook', methods=['POST']) @@ -213,6 +213,9 @@ def add_application_sla_policy(app_id): report_statuses = {} def add_new_scan(git_url, branch_name, report_id): + # Configure logging + logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') + try: stage_str = _determine_stages_for_app(git_url, branch_name) headers = { @@ -228,10 +231,14 @@ def add_new_scan(git_url, branch_name, report_id): } url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) - time.sleep(10) # sleep for 10 seconds to allow time for response - # response = jsonify({"Status": resp.status_code}), 200 + # Log the response details + logging.info(f"Request URL: {url}") + logging.info(f"Response Status Code: {resp.status_code}") + logging.info(f"Response Text: {resp.text}") except requests.exceptions.Timeout: - print('Processing Error') + logging.error('Processing Error: Timeout') + except Exception as e: + logging.error(f'Unexpected error: {str(e)}') def _determine_stages_for_app(git_url, branch_name): From e5e42edf41b978824cf6eb94a5c85a9c8dcac411 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 13:47:29 -0700 Subject: [PATCH 097/197] Feature/jenkins updates (#531) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py --- src/vr/api/vulns/jenkins_webhook.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/vr/api/vulns/jenkins_webhook.py b/src/vr/api/vulns/jenkins_webhook.py index f3c40868..2411defe 100644 --- a/src/vr/api/vulns/jenkins_webhook.py +++ b/src/vr/api/vulns/jenkins_webhook.py @@ -21,7 +21,7 @@ from vr.vulns.model.sgglobalthresholds import SgGlobalThresholds from vr.admin.functions import db_connection_handler import traceback -import time +import logging @api.route('/api/jenkins_webhook', methods=['POST']) @@ -213,6 +213,9 @@ def add_application_sla_policy(app_id): report_statuses = {} def add_new_scan(git_url, branch_name, report_id): + # Configure logging + logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') + try: stage_str = _determine_stages_for_app(git_url, branch_name) headers = { @@ -228,10 +231,14 @@ def add_new_scan(git_url, branch_name, report_id): } url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) - time.sleep(10) # sleep for 10 seconds to allow time for response - # response = jsonify({"Status": resp.status_code}), 200 + # Log the response details + logging.info(f"Request URL: {url}") + logging.info(f"Response Status Code: {resp.status_code}") + logging.info(f"Response Text: {resp.text}") except requests.exceptions.Timeout: - print('Processing Error') + logging.error('Processing Error: Timeout') + except Exception as e: + logging.error(f'Unexpected error: {str(e)}') def _determine_stages_for_app(git_url, branch_name): From ce480bf435b6dae20b44a89cd33aae0726db2d8d Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 13:50:33 -0700 Subject: [PATCH 098/197] Release/0.1.0 beta/prod azure (#532) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile * Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * Feature/update settings function (#501) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * Feature/update release based db settings (#503) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * Feature/update release based db settings (#505) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#507) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#509) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Feature/fix syntax error (#511) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Feature/fix syntax error (#513) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Feature/fix syntax error (#515) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * Feature/fix syntax error (#517) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Feature/jenkins updates (#519) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Feature/jenkins updates (#521) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Feature/jenkins updates (#523) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Feature/jenkins updates (#525) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Feature/jenkins updates (#527) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Feature/jenkins updates (#529) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Feature/jenkins updates (#531) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py --- src/vr/api/vulns/jenkins_webhook.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/vr/api/vulns/jenkins_webhook.py b/src/vr/api/vulns/jenkins_webhook.py index f3c40868..2411defe 100644 --- a/src/vr/api/vulns/jenkins_webhook.py +++ b/src/vr/api/vulns/jenkins_webhook.py @@ -21,7 +21,7 @@ from vr.vulns.model.sgglobalthresholds import SgGlobalThresholds from vr.admin.functions import db_connection_handler import traceback -import time +import logging @api.route('/api/jenkins_webhook', methods=['POST']) @@ -213,6 +213,9 @@ def add_application_sla_policy(app_id): report_statuses = {} def add_new_scan(git_url, branch_name, report_id): + # Configure logging + logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') + try: stage_str = _determine_stages_for_app(git_url, branch_name) headers = { @@ -228,10 +231,14 @@ def add_new_scan(git_url, branch_name, report_id): } url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) - time.sleep(10) # sleep for 10 seconds to allow time for response - # response = jsonify({"Status": resp.status_code}), 200 + # Log the response details + logging.info(f"Request URL: {url}") + logging.info(f"Response Status Code: {resp.status_code}") + logging.info(f"Response Text: {resp.text}") except requests.exceptions.Timeout: - print('Processing Error') + logging.error('Processing Error: Timeout') + except Exception as e: + logging.error(f'Unexpected error: {str(e)}') def _determine_stages_for_app(git_url, branch_name): From a843f29df1c55176b2bb5520ca5a70fa1c36a3f4 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 14:49:15 -0700 Subject: [PATCH 099/197] Update jenkins_webhook.py --- src/vr/api/vulns/jenkins_webhook.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/vr/api/vulns/jenkins_webhook.py b/src/vr/api/vulns/jenkins_webhook.py index 2411defe..73a9bd23 100644 --- a/src/vr/api/vulns/jenkins_webhook.py +++ b/src/vr/api/vulns/jenkins_webhook.py @@ -212,9 +212,21 @@ def add_application_sla_policy(app_id): # Global dictionary to keep track of report statuses report_statuses = {} +# Create a logger object for this module or function +logger = logging.getLogger('add_new_scan') +logger.setLevel(logging.INFO) # Set the desired log level + +# Create a stream handler to output logs to stdout +stream_handler = logging.StreamHandler() +stream_handler.setLevel(logging.INFO) + +# Optionally, set a formatter for the handler +formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') +stream_handler.setFormatter(formatter) + +# Add the handler to the logger +logger.addHandler(stream_handler) def add_new_scan(git_url, branch_name, report_id): - # Configure logging - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') try: stage_str = _determine_stages_for_app(git_url, branch_name) @@ -232,13 +244,13 @@ def add_new_scan(git_url, branch_name, report_id): url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) # Log the response details - logging.info(f"Request URL: {url}") - logging.info(f"Response Status Code: {resp.status_code}") - logging.info(f"Response Text: {resp.text}") + logger.info(f"Request URL: {url}") + logger.info(f"Response Status Code: {resp.status_code}") + logger.info(f"Response Text: {resp.text}") except requests.exceptions.Timeout: - logging.error('Processing Error: Timeout') + logger.error('Processing Error: Timeout') except Exception as e: - logging.error(f'Unexpected error: {str(e)}') + logger.error(f'Unexpected error: {str(e)}') def _determine_stages_for_app(git_url, branch_name): From feebb211ad46b657d52ea0dce0baa1911913f394 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 14:55:56 -0700 Subject: [PATCH 100/197] Feature/jenkins updates (#533) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py --- src/vr/api/vulns/jenkins_webhook.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/vr/api/vulns/jenkins_webhook.py b/src/vr/api/vulns/jenkins_webhook.py index 2411defe..73a9bd23 100644 --- a/src/vr/api/vulns/jenkins_webhook.py +++ b/src/vr/api/vulns/jenkins_webhook.py @@ -212,9 +212,21 @@ def add_application_sla_policy(app_id): # Global dictionary to keep track of report statuses report_statuses = {} +# Create a logger object for this module or function +logger = logging.getLogger('add_new_scan') +logger.setLevel(logging.INFO) # Set the desired log level + +# Create a stream handler to output logs to stdout +stream_handler = logging.StreamHandler() +stream_handler.setLevel(logging.INFO) + +# Optionally, set a formatter for the handler +formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') +stream_handler.setFormatter(formatter) + +# Add the handler to the logger +logger.addHandler(stream_handler) def add_new_scan(git_url, branch_name, report_id): - # Configure logging - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') try: stage_str = _determine_stages_for_app(git_url, branch_name) @@ -232,13 +244,13 @@ def add_new_scan(git_url, branch_name, report_id): url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) # Log the response details - logging.info(f"Request URL: {url}") - logging.info(f"Response Status Code: {resp.status_code}") - logging.info(f"Response Text: {resp.text}") + logger.info(f"Request URL: {url}") + logger.info(f"Response Status Code: {resp.status_code}") + logger.info(f"Response Text: {resp.text}") except requests.exceptions.Timeout: - logging.error('Processing Error: Timeout') + logger.error('Processing Error: Timeout') except Exception as e: - logging.error(f'Unexpected error: {str(e)}') + logger.error(f'Unexpected error: {str(e)}') def _determine_stages_for_app(git_url, branch_name): From bb848956b6e69a1ae017f46b143ff168ea263b71 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Fri, 22 Mar 2024 14:56:55 -0700 Subject: [PATCH 101/197] Release/0.1.0 beta/prod azure (#534) * Update pipeline-config.yaml (#440) * Update tox.ini (#441) * Feature/fix toxi (#443) * Update tox.ini * fix unit test failures * Feature/fix toxi (#445) * Update tox.ini * fix unit test failures * Update web_testing.py * Feature/fix toxi (#447) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * Feature/fix toxi (#449) * Update tox.ini * fix unit test failures * Update web_testing.py * Update Jenkinsfile * add dockerImg map for Container scans * Update Jenkinsfile (#452) * Feature/jenkinsfile updates (#453) * Update Jenkinsfile * added scores and grades api endpoint * Feature/jenkinsfile updates (#455) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Feature/jenkinsfile updates (#457) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Feature/jenkinsfile updates (#459) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Feature/jenkinsfile updates (#461) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#463) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#465) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#467) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Feature/jenkinsfile updates (#469) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * Update Jenkinsfile * Update pipeline-config.yaml * Update values.yaml * Update values.yaml * Update Jenkinsfile * Update values.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#473) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * Feature/jenkinsfile updates (#474) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Feature/jenkinsfile updates (#476) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Feature/jenkinsfile updates (#478) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#481) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * Feature/jenkinsfile updates (#483) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Feature/jenkinsfile updates (#485) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Feature/jenkinsfile updates (#487) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update pipeline-config.yaml * Feature/jenkinsfile updates (#490) * Update Jenkinsfile * added scores and grades api endpoint * Update Jenkinsfile * Update Jenkinsfile * Update pipeline-config.yaml * Update pipeline-config.yaml * Update pipeline-config.yaml * Update Jenkinsfile * Update sgglobalthresholds.py * Update initial_setup.py * add conditions for jenkins and snow integrations * add settings for Jenkins * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile * jenkins testing * Update vulnerabilities.py * Update pipeline-config.yaml * Update Jenkinsfile * Update pipeline-config.yaml * Update Jenkinsfile (#493) * Update security_quality_gate.py (#495) * Feature/update jenkins config (#497) * Update security_quality_gate.py * Update Jenkinsfile * Feature/update security gate config (#499) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * Feature/update settings function (#501) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * Feature/update release based db settings (#503) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * Feature/update release based db settings (#505) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#507) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Feature/fix db syntax (#509) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Feature/fix syntax error (#511) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Feature/fix syntax error (#513) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Feature/fix syntax error (#515) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * Feature/fix syntax error (#517) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Feature/jenkins updates (#519) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Feature/jenkins updates (#521) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Feature/jenkins updates (#523) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Feature/jenkins updates (#525) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Feature/jenkins updates (#527) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Feature/jenkins updates (#529) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Feature/jenkins updates (#531) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Feature/jenkins updates (#533) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py --- src/vr/api/vulns/jenkins_webhook.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/vr/api/vulns/jenkins_webhook.py b/src/vr/api/vulns/jenkins_webhook.py index 2411defe..73a9bd23 100644 --- a/src/vr/api/vulns/jenkins_webhook.py +++ b/src/vr/api/vulns/jenkins_webhook.py @@ -212,9 +212,21 @@ def add_application_sla_policy(app_id): # Global dictionary to keep track of report statuses report_statuses = {} +# Create a logger object for this module or function +logger = logging.getLogger('add_new_scan') +logger.setLevel(logging.INFO) # Set the desired log level + +# Create a stream handler to output logs to stdout +stream_handler = logging.StreamHandler() +stream_handler.setLevel(logging.INFO) + +# Optionally, set a formatter for the handler +formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') +stream_handler.setFormatter(formatter) + +# Add the handler to the logger +logger.addHandler(stream_handler) def add_new_scan(git_url, branch_name, report_id): - # Configure logging - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') try: stage_str = _determine_stages_for_app(git_url, branch_name) @@ -232,13 +244,13 @@ def add_new_scan(git_url, branch_name, report_id): url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) # Log the response details - logging.info(f"Request URL: {url}") - logging.info(f"Response Status Code: {resp.status_code}") - logging.info(f"Response Text: {resp.text}") + logger.info(f"Request URL: {url}") + logger.info(f"Response Status Code: {resp.status_code}") + logger.info(f"Response Text: {resp.text}") except requests.exceptions.Timeout: - logging.error('Processing Error: Timeout') + logger.error('Processing Error: Timeout') except Exception as e: - logging.error(f'Unexpected error: {str(e)}') + logger.error(f'Unexpected error: {str(e)}') def _determine_stages_for_app(git_url, branch_name): From c3d91bece57ac6eec9eed0418dbac1727ad2de8e Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sat, 23 Mar 2024 08:17:27 -0700 Subject: [PATCH 102/197] add new route for updating application profile --- .../templates/vulns/application_profile.html | 20 ++++++--- src/vr/vulns/web/testing.py | 41 ++++++++++++++++++- 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/src/vr/templates/vulns/application_profile.html b/src/vr/templates/vulns/application_profile.html index 558b0f04..139c4e67 100644 --- a/src/vr/templates/vulns/application_profile.html +++ b/src/vr/templates/vulns/application_profile.html @@ -38,10 +38,6 @@

Application Profile

- - - -
@@ -57,7 +53,18 @@
- diff --git a/src/vr/vulns/web/testing.py b/src/vr/vulns/web/testing.py index c69f7122..59defe1d 100644 --- a/src/vr/vulns/web/testing.py +++ b/src/vr/vulns/web/testing.py @@ -127,6 +127,45 @@ def on_demand_testing(): return redirect(request.referrer) +@vulns.route("/update_application_profile", methods=['POST']) +@login_required +def update_application_profile(): + NAV['curpage'] = {"name": "Vulnerability Scans"} + admin_role = 'Application Admin' + role_req = ['Application Admin', 'Application Viewer'] + perm_entity = 'Application' + user, status, user_roles = _auth_user(session, NAV['CAT']['name'], role_requirements=role_req, + permissions_entity=perm_entity) + status = _entity_page_permissions_filter(id, user_roles, session, admin_role) + + if status == 401: + return redirect(url_for('admin.login')) + elif status == 403: + return render_template('403.html', user=user, NAV=NAV) + + git_url = request.form.get('gitUrl') + git_branch = request.form.get('gitBranch') + app_name = request.form.get('app_name') + tests_to_run = 'NONE,' + + headers = { + "Accept": "application/json", + "Content-Type": "application/x-www-form-urlencoded" + } + data = { + 'token': app.config['JENKINS_TOKEN'], + 'GIT_URL': git_url, + 'TESTS': tests_to_run.upper(), + 'GIT_BRANCH': git_branch, + 'APP_NAME': app_name, + 'PROFILE_APPLICATION': 'Y' + } + url = f"{app.config['JENKINS_HOST']}/job/{app.config['JENKINS_PROJECT']}/buildWithParameters" + resp = requests.post(url, headers=headers, data=data, auth=HTTPBasicAuth(app.config['JENKINS_USER'], app.config['JENKINS_KEY'])) + + return redirect(request.referrer) + + @vulns.route("/application_profile/") @login_required def application_profile(app_id): @@ -145,7 +184,7 @@ def application_profile(app_id): filter(lambda t: t.ID != '', assets_all) ) app = BusinessApplications.query.filter(text(f'ID={app_id}')).first() - app_data = {'ID': app_id, 'ApplicationName': app.ApplicationName, 'Component': app.ApplicationAcronym} + app_data = {'ID': app_id, 'ApplicationName': app.ApplicationName, 'Component': app.ApplicationAcronym, 'RepoURL': app.RepoURL} NAV['appbar'] = 'settings' return render_template('vulns/application_profile.html', entities=assets, user=user, NAV=NAV, app_data=app_data) From 3a610b54c1b7ef044f666c926c75f90450f6ac18 Mon Sep 17 00:00:00 2001 From: bkaiserinfosec <49665796+bkaiserinfosec@users.noreply.github.com> Date: Sat, 23 Mar 2024 08:23:52 -0700 Subject: [PATCH 103/197] Feature/add app profile update function (#535) * Update security_quality_gate.py * Update Jenkinsfile * Update security_quality_gate.py * update settings and groups * add function for table updates * updated function for db updates * Update updates.py * Update updates.py * Update updates.py * Update settings.py * update to settings update without restart * Update run.py * Update pipeline-config.yaml * Update __init__.py * Update __init__.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py * Update jenkins_webhook.py * add new route for updating application profile --- .../templates/vulns/application_profile.html | 20 ++++++--- src/vr/vulns/web/testing.py | 41 ++++++++++++++++++- 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/src/vr/templates/vulns/application_profile.html b/src/vr/templates/vulns/application_profile.html index 558b0f04..139c4e67 100644 --- a/src/vr/templates/vulns/application_profile.html +++ b/src/vr/templates/vulns/application_profile.html @@ -38,10 +38,6 @@

Application Profile

- - - - @@ -57,7 +53,18 @@