abrar0503 commited on
Commit
55e4b0c
·
verified ·
1 Parent(s): 274f053

Upload 13 files

Browse files
.gitignore ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # IDE
2
+ .idea/
3
+ *.iml
4
+
5
+ # Environments
6
+ .venv
7
+
8
+ # Packaging Artifacts
9
+ dist/
10
+ ssap_bill_of_materials/
11
+ requirements.txt
12
+
13
+ # Test Artifacts
14
+ .coverage
15
+ reports/
16
+ .pytest_cache/
17
+ __pycache__/
.kickstart.yml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ starterName: "pythonLambda"
3
+ starterVersion: "1.5.1"
4
+ starterLibraries:
5
+ - "kickstart-control-library:1.0.4"
6
+ scope: "CTC"
7
+ inputs:
8
+ - name: "projectName"
9
+ value: "python-raven-vulnerability"
10
+ - name: "sealId"
11
+ value: "123456"
12
+ - name: "awsRegion"
13
+ value: "usEast1"
14
+ - name: "environment"
15
+ value: "dev"
16
+ - name: "architecture"
17
+ value: "event"
18
+ - name: "lambdaName[0]"
19
+ value: "do-nothing-lambda"
20
+ generated: "2024.07.31-14.06.11"
Jenkinsfile ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!groovy
2
+ @Library('[email protected]') _
3
+
4
+ // keep 5 builds
5
+ properties([buildDiscarder(logRotator(numToKeepStr: '5'))])
6
+
7
+ buildPipeline()
8
+
9
+ def buildPipeline() {
10
+ jules_pipelineRunner {
11
+ yml = 'jules.yml'
12
+ }
13
+ }
Makefile ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Grabs the list of packages from pyproject.toml
2
+ PACKAGES := $(shell for pkg in `grep -o '"\.\.\/.*"' pyproject.toml | sed -e 's/"//g'`; do echo $$pkg; done)
3
+
4
+ .PHONY: all
5
+ .DEFAULT_GOAL=help
6
+
7
+ .PHONY: clean
8
+ clean:
9
+ rm -f .coverage
10
+ rm -f requirements.txt
11
+ rm -rf .pytest_cache
12
+ rm -rf dist
13
+ rm -rf reports
14
+
15
+ .PHONY: distclean
16
+ distclean: clean ## Remove all build and test artifacts and the virtual environment
17
+ rm -rf .venv
18
+
19
+ .PHONY: build
20
+ build: ## Create the virtual environment and install development dependencies
21
+ python -m poetry install
22
+
23
+ .PHONY: update
24
+ update: ## Update dependencies
25
+ python -m poetry update
26
+
27
+ .PHONY: test
28
+ test: ## Execute test cases
29
+ python -m poetry run pytest
30
+
31
+ .PHONY: cover
32
+ cover: ## Execute test cases and produce coverage reports
33
+ python -m poetry run pytest --cov . --junitxml reports/xunit.xml \
34
+ --cov-report xml:reports/coverage.xml --cov-report term-missing
35
+
36
+ .PHONY: ssap
37
+ ssap: ## Generates requirements.txt file
38
+ python -m poetry export --without-hashes -o requirements.txt
39
+
40
+ .PHONY: collect-wheels
41
+ collect-wheels: ## Collects all wheels under a single folder
42
+ @mkdir -p dist/wheels
43
+ @for pkg in $(PACKAGES); do cp $$pkg/dist/*.whl dist/wheels; done
44
+ @cp dist/*.whl dist/wheels
45
+
46
+ .PHONY: package
47
+ package: package-build collect-wheels ## Create lambda deployable zip packages for each lambda
48
+ @mkdir -p dist/package-exploded dist/package
49
+ $(eval WHEELS=$(shell ls dist/wheels))
50
+ @cd dist/wheels && pip install --platform manylinux2014_x86_64 --only-binary=:all: --implementation cp --target ../package-exploded $(WHEELS)
51
+ @cd dist/package-exploded && zip -x "*__pycache__*" -x "*dist-info*" -r ../package/lambda.zip *
52
+
53
+ .PHONY: package-build
54
+ package-build: ## Builds source and wheels archive
55
+ python -m poetry build
56
+
57
+ .PHONY: help
58
+ help: ## Show make target documentation
59
+ @awk -F ':|##' '/^[^\t].+?:.*?##/ {\
60
+ printf "\033[36m%-30s\033[0m %s\n", $$1, $$NF \
61
+ }' $(MAKEFILE_LIST)
README.md ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python Raven Vulnerability
2
+
3
+ ## Setup
4
+
5
+ `python -m pip install --upgrade poetry` to install Poetry
6
+
7
+ ## Lambdas
8
+
9
+ The project contains the following lambdas under the lambdas directory
10
+
11
+ * do-nothing-lambda
12
+
13
+ ## Local Mode
14
+
15
+ * `make build` to resolve and install dependencies
16
+ * `make test` to execute the tests
17
+ * `make package` to create deployable zipped packages
18
+ * `make help` to see a list of all available commands
19
+
20
+ ### Deploying the Lambda from Local
21
+
22
+ The Lambda should be deployed by publishing a new version to AWS which is referenced by the Lambda infrastructure using
23
+ the "live" alias, therefore deploying the Lambda is a two step process:
24
+
25
+ 1. Publish a new version of the Lambda
26
+
27
+ `aws lambda update-function-code --function-name app-<lambda-name> --publish --zip-file fileb://<path to zip file>`
28
+
29
+ Note the Lambda version in the response.
30
+
31
+ 2. Update the "live" alias
32
+
33
+ `aws lambda update-alias --function-name app-<lambda name> --name live --function-version <lambda version>`
34
+
35
+ The "live" alias is updated automatically when deploying through jules.
jules.yml ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ sealId: 123456
2
+ node: python-3.10
3
+ baseVersion: 1.0.0
4
+ aim:
5
+ entitleAdmin: 'REPLACE_WITH_AIM_ENTITLEMENT'
6
+ collection: 'REPLACE_WITH_AIM_COLLECTION'
7
+ ru: python-raven-vulnerability
8
+ artifact: python-raven-vulnerability
9
+ script: cp dist/*.zip fileupload/
10
+ buildConfig:
11
+ buildType: python
12
+ env:
13
+ variables:
14
+ - IDENTITY_SOURCE_LAMBDA: JET
15
+ - IDENTITY_SOURCE_AIM: JET
16
+ sonarDetails:
17
+ additionalProperties: >-
18
+ -Dsonar.language=py
19
+ -Dsonar.python.coverage.reportPaths=reports/**/coverage.xml
20
+ -Dsonar.sources=lambdas/
21
+ -Dsonar.inclusions=lambdas/**/src/**/*
22
+ -Dsonar.python.xunit.reportPath=reports/**/xunit.xml
23
+ -Dsonar.verbose=true
24
+ testsight:
25
+ enabled: true
26
+ testReportDir: 'reports'
27
+ aws:
28
+ endpointType: lambda
29
+ mapping:
30
+ - name: default
31
+ build: --version
32
+ tasks:
33
+ preBuild:
34
+ - script: make ci-prebuild
35
+ - script: make ci
36
+ postBuild:
37
+ - script: make cover
38
+ postTest:
39
+ - script: make ssap
40
+ - name: develop
41
+ build: --version
42
+ tasks:
43
+ preBuild:
44
+ - script: make ci-prebuild
45
+ - script: make ci
46
+ postBuild:
47
+ - script: make cover
48
+ postTest:
49
+ - script: make ssap
50
+ awsDeployment:
51
+ - env: dev
52
+ accountId: 'REPLACE_WITH_AWS_DEV_ACCOUNT'
53
+ role: 123456-application-engineer
54
+ regions:
55
+ - region: us-east-1
56
+ functions:
57
+ - function: app-do-nothing-lambda
58
+ packageName: do-nothing-lambda.zip
59
+ publish: true
60
+ updateAliases:
61
+ - name: live
62
+ - name: master
63
+ build: --version
64
+ preReleaseScans: true
65
+ tasks:
66
+ preBuild:
67
+ - script: make ci-prebuild
68
+ - script: make ci
69
+ postBuild:
70
+ - script: make cover
71
+ postTest:
72
+ - script: make ssap
73
+ awsDeployment:
74
+ - env: test
75
+ accountId: 'REPLACE_WITH_AWS_TEST_ACCOUNT'
76
+ role: 123456-application-operator
77
+ regions:
78
+ - region: us-east-1
79
+ functions:
80
+ - function: app-do-nothing-lambda
81
+ packageName: do-nothing-lambda.zip
82
+ publish: true
83
+ updateAliases:
84
+ - name: live
85
+ - env: prod
86
+ accountId: 'REPLACE_WITH_AWS_PROD_ACCOUNT'
87
+ role: 123456-application-operator
88
+ regions:
89
+ - region: us-east-1
90
+ functions:
91
+ - function: app-do-nothing-lambda
92
+ packageName: do-nothing-lambda.zip
93
+ publish: true
94
+ updateAliases:
95
+ - name: live
poetry.toml ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [virtualenvs]
2
+ in-project = true
pyproject.toml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [tool.poetry]
2
+ name = "do-nothing-lambda"
3
+ version = "1.0.0"
4
+ description = "Do Nothing Lambda"
5
+ authors = ["JPMC <[email protected]>"]
6
+
7
+ [[tool.poetry.source]]
8
+ name = "artifacts"
9
+ url = "https://artifacts-read.gkp.jpmchase.net/artifactory/api/pypi/pypi/simple"
10
+ default = true
11
+
12
+ [tool.poetry.dependencies]
13
+ python = "^3.10"
14
+
15
+ [tool.poetry.group.dev.dependencies]
16
+ boto3 = "==1.34.102"
17
+ botocore = "==1.34.102"
18
+
19
+ [tool.poetry.group.test.dependencies]
20
+ pytest = "==8.2.0"
21
+ coverage = "==7.5.1"
22
+ pytest-cov = "==5.0.0"
23
+
24
+ [build-system]
25
+ requires = ["poetry-core>=1.0.0"]
26
+ build-backend = "poetry.core.masonry.api"
requirements.txt ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ matplotlib==3.6.2
2
+ # via
3
+ # -r requirements.in
4
+ # seaborn
5
+ numpy==1.23.5
6
+ # via
7
+ # -r requirements.in
8
+ # contourpy
9
+ # matplotlib
10
+ # pandas
11
+ # scipy
12
+ # seaborn
13
+ pandas==1.5.1
14
+ # via
15
+ # -r requirements.in
16
+ # seaborn
17
+ Flask-Caching==2.3.0
src/do_nothing_lambda/__init__.py ADDED
File without changes
src/do_nothing_lambda/handler.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+
3
+
4
+ logger = logging.getLogger()
5
+ logger.setLevel(logging.INFO)
6
+
7
+
8
+ def execute(event, context):
9
+ logger.info("Received Event: %s", event)
test/__init__.py ADDED
File without changes
test/test_handler.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ from do_nothing_lambda.handler import execute
2
+
3
+
4
+ def test_handler():
5
+ assert True