Skip to content

Commit 14c22b9

Browse files
committed
[XDR-22278] Update, rebuild and redeploy integrations
add actions, Makefile, add black update linter
1 parent be97fa2 commit 14c22b9

29 files changed

+1386
-895
lines changed

.flake8

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[flake8]
2+
max-line-length = 120
3+
exclude = */payloads_for_tests.py
4+
per-file-ignores =
5+
code/api/__init__.py:E402,F401
6+
code/api/mapping/__init__.py:E402,F401
7+
code/api/transformations/__init__.py:E402,F401

.github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
pull-request-branch-name:
8+
separator: "-"

.github/workflows/test.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Pipenv Install and Test
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
7+
8+
jobs:
9+
unittests:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
15+
- name: Install Python, pipenv and Pipfile packages
16+
uses: palewire/install-python-pipenv-pipfile@v4
17+
with:
18+
python-version: 3.11
19+
20+
- name: Run tests
21+
run: |
22+
pipenv install --dev
23+
cd code/
24+
pipenv run coverage run --source api/ -m pytest --verbose tests/unit/
25+
pipenv run coverage report --fail-under=80
26+
27+
- name: Run pip-audit
28+
run: pipenv run pip-audit

Dockerfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
FROM alpine:3.14
2-
LABEL maintainer="Ian Redden <iaredden@cisco.com>"
1+
FROM alpine:3.18
2+
LABEL maintainer="Jyoti Verma jyoverma@cisco.com"
33

4-
ENV PIP_IGNORE_INSTALLED 1
4+
ENV PIP_IGNORE_INSTALLED=1
55

66
# install packages we need
77
RUN apk update && apk add --no-cache musl-dev openssl-dev gcc py3-configobj \
@@ -10,7 +10,7 @@ py3-pip python3-dev
1010

1111
# do the Python dependencies
1212
ADD code /app
13-
ADD code/Pipfile code/Pipfile.lock /
13+
ADD Pipfile Pipfile.lock /
1414
RUN set -ex && pip install --no-cache-dir --upgrade pipenv && \
1515
pipenv install --system
1616
RUN chown -R uwsgi.uwsgi /etc/uwsgi

Makefile

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
NAME_SHORT:="tr-05-rsa-netwitness"
2+
NAME:=ciscosecurity/$(NAME_SHORT)
3+
PORT:="9090"
4+
PLATFORM=--platform linux/amd64,linux/arm64
5+
VERSION:=$(shell jq '.VERSION' code/container_settings.json | tr -d '"')
6+
7+
all: env stop build test scout
8+
9+
run: # app locally
10+
cd code; python -m app; cd -
11+
12+
# Docker
13+
build: stop
14+
docker buildx build $(PLATFORM) -t $(NAME):$(VERSION) -t $(NAME):latest .
15+
start: build
16+
docker run -dp $(PORT):$(PORT) --name $(NAME_SHORT) $(NAME):$(VERSION)
17+
stop:
18+
docker stop $(NAME_SHORT); docker rm $(NAME_SHORT); true
19+
release: build
20+
docker login
21+
docker image push --all-tags $(NAME)
22+
@echo "https://hub.docker.com/repository/docker/$(NAME)/tags"
23+
24+
# Tools
25+
env:
26+
pip install --no-cache-dir --upgrade pipenv && pipenv install --dev
27+
black:
28+
black code/ -l 120 -t py311 --exclude=payloads_for_tests.py
29+
lint: black
30+
flake8 code/
31+
32+
# Tests
33+
check: lint
34+
curl -sSfL https://raw.githubusercontent.com/docker/scout-cli/main/install.sh | sh -s --
35+
docker scout cves $(NAME) --only-fixed
36+
pip-audit
37+
test: lint
38+
cd code; coverage run --source api/ -m pytest --verbose tests/unit/ && coverage report --fail-under=80; cd -
39+
test_lf: lint
40+
cd code; coverage run --source api/ -m pytest --verbose -vv --lf tests/unit/ && coverage report -m --fail-under=80; cd -
41+

Pipfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
cryptography = "==44.0.2"
8+
Flask = "==3.1.0"
9+
marshmallow = "==3.25.1"
10+
requests = "==2.32.3"
11+
PyJWT = "==2.6.0"
12+
13+
[dev-packages]
14+
black = "==25.1.0"
15+
coverage = "==7.6.12"
16+
flake8 = "==7.1.2"
17+
pip-audit = "==2.8.0"
18+
pytest = "==8.3.5"
19+
20+
[requires]
21+
python_version = "3.11"

Pipfile.lock

+970
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/Pipfile

-19
This file was deleted.

0 commit comments

Comments
 (0)