Skip to content

Commit d78c03b

Browse files
Merge branch 'feature_bandit_#30' into 'master'
Integrate bandit as pipeline security stage job. #30 Closes #36 and #30 See merge request aleksandr-kotlyar/python_and_gitlab!76
2 parents 78ac00e + 7947690 commit d78c03b

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

.gitlab/.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
image: registry.gitlab.com/aleksandr-kotlyar/python_and_gitlab/python-3.7.6-alpine-req:ver-13-ssl-fix
1+
image: registry.gitlab.com/aleksandr-kotlyar/python_and_gitlab/python-3.7.6-alpine-req:ver-14-mimesis-4.1.2
22

33
stages:
44
- build

.gitlab/security.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,13 @@ Trivy:
2727
- trivy filesystem --exit-code 1 --skip-dirs /builds/gitlab-org-forks/ --cache-dir .trivycache/ /
2828
tags:
2929
- gitlab-org
30+
31+
Bandit:
32+
stage: security
33+
rules:
34+
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "push"'
35+
script:
36+
- pip3 install bandit
37+
- bandit -x $(pwd)/.venv/ -r $(pwd) -s B101
38+
tags:
39+
- gitlab-org

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
FROM python:3.7.6-alpine
2-
COPY requirements.txt /app/requirements.txt
32
WORKDIR /app
43
RUN apk --no-cache -U add curl \
54
gcc \
65
libc-dev \
76
libcrypto1.1=1.1.1g-r0 \
87
libssl1.1=1.1.1g-r0 \
98
sqlite-libs=3.30.1-r2
9+
COPY requirements.txt /app/requirements.txt
1010
RUN pip3 install --no-cache-dir -r requirements.txt

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ anybadge==1.6.2
1111
voluptuous==0.11.7
1212
pytest-voluptuous==1.1.0
1313
curlify==2.2.1
14-
webdriver_manager==2.3.0
14+
webdriver_manager==2.3.0
15+
mimesis==4.1.2

src/test/test_duplicates.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import logging
2-
import random
32
from collections import defaultdict
43
from logging import info
54

65
from assertpy import soft_assertions, assert_that
6+
from mimesis.random import Random
77
from pytest import mark
88

99
SOMETHING = [
@@ -36,14 +36,10 @@ def test_list_of_dictionaries_does_not_duplicate_by_some_key_value():
3636
f'key "{key}"" has duplicates "{new_some_view[key]}"').is_less_than_or_equal_to(1)
3737

3838

39-
def random_list(start, stop, _len):
40-
return [random.randint(start, stop) for i in range(_len)]
41-
42-
4339
@mark.parametrize('some_list', [
44-
([20, 30, 20, 30, 40, 50, 15, 11, 20, 40, 50, 15, 6, 7]),
45-
([9, 5, 4]),
46-
random_list(start=0, stop=4, _len=4),
40+
[20, 30, 20, 30, 40, 50, 15, 11, 20, 40, 50, 15, 6, 7],
41+
[9, 5, 4],
42+
Random().randints(20, 0, 10),
4743
])
4844
def test_list_doesnt_have_duplicates(some_list):
4945
some_list.sort()

0 commit comments

Comments
 (0)