Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
95bd22f
Add pylint test
Metodil Nov 11, 2024
5115172
Run on push
Metodil Nov 11, 2024
efe7489
Check .editorconfig
Metodil Nov 11, 2024
35db86c
Add markdown-link-check
Metodil Nov 11, 2024
0c97638
Add unit test with app_test.py
Metodil Nov 11, 2024
0e5cc34
Ajust unit test
Metodil Nov 11, 2024
9c64c19
Ajust workflow triger to pull_request
Metodil Nov 11, 2024
cc090f1
Ajust u34-hw
Metodil Nov 11, 2024
f610da8
pull_request
Metodil Nov 11, 2024
15ac604
remove paths in u34-hw
Metodil Nov 11, 2024
039a2c4
ajust unit test
Metodil Nov 11, 2024
6626c71
Ajust unit-test add lint check
Metodil Nov 11, 2024
b7d970b
Ajust lint-unit-test
Metodil Nov 11, 2024
5c4ff3d
Ajust u34-hw add needs requiremnt and edit .editorconfig
Metodil Nov 11, 2024
08577de
triger workflow
Metodil Nov 11, 2024
dd7da60
Ajust name of var
Metodil Nov 11, 2024
f361fe3
Ajust var name
Metodil Nov 11, 2024
8ffd156
remove RUNONIMAGE var
Metodil Nov 11, 2024
521ec72
comment pylint test
Metodil Nov 11, 2024
2f17c06
add security test and docker build, test and deploy
Metodil Nov 11, 2024
1300403
fix syntax in yml
Metodil Nov 11, 2024
3fd9422
fix syntax in yml 2
Metodil Nov 11, 2024
28e6b98
Add sonar cloud test
Metodil Nov 11, 2024
a1410a3
Set proper version on sonar cloud
Metodil Nov 11, 2024
7925027
add sonar-project.properties
Metodil Nov 11, 2024
4602dca
Ajust sonar-project
Metodil Nov 11, 2024
879641d
add .gitleaks.toml
Metodil Nov 11, 2024
0bf7675
Finaly proper projectkey in sonar cloud
Metodil Nov 11, 2024
2d4d591
check with pylint and security scan with trivy fs
Metodil Nov 12, 2024
9ae09d1
Ajust pull_request triger
Metodil Nov 12, 2024
ab437ca
set test order in lint-unit-tests
Metodil Nov 12, 2024
eb3623e
Ajust pylint err missing modules
Metodil Nov 12, 2024
c242ac4
add .pylintrc with settings
Metodil Nov 12, 2024
edff86d
ajust path to .pylintrc
Metodil Nov 12, 2024
a4756d5
disable workin test for save time
Metodil Nov 12, 2024
212907d
set syntax err
Metodil Nov 12, 2024
d0e20c1
Set others missing docring in .pylintrc
Metodil Nov 12, 2024
800ad34
try other setings in .pylintrc
Metodil Nov 12, 2024
c0bb8ed
fix security-scan with Trivy
Metodil Nov 12, 2024
c48140e
ajust trivy docker container test
Metodil Nov 12, 2024
8302492
ajust buld test and push
Metodil Nov 12, 2024
d72745d
increase ver of hashi vault action
Metodil Nov 12, 2024
74b6ef7
arrange all test
Metodil Nov 12, 2024
5a88bbe
add lint with black
Metodil Nov 12, 2024
f1cc38c
add pre-commit.yml
Metodil Nov 12, 2024
9d7378a
rm pre-commit.yml
Metodil Nov 12, 2024
d8bee40
add pre-commit-config.yaml
Metodil Nov 12, 2024
9694615
set other hooks in pre-commit-config.yaml
Metodil Nov 12, 2024
f503673
add compose.yaml build ans run container
Metodil Nov 12, 2024
23df0d5
add schedule in workflow on Monday (1) and Thursday (4)
Metodil Nov 12, 2024
c71c771
reorganizing the repo as per the requirements
Metodil Nov 13, 2024
ff012f7
fix buils-test and deploy only if prev tesk ok
Metodil Nov 13, 2024
ea3b60d
fix security in app/requiremnt.txt
Metodil Nov 13, 2024
5b931f0
fix some err from sonar cloud
Metodil Nov 13, 2024
6114cdd
fix ci-pipeline build-test
Metodil Nov 13, 2024
57bce07
fix perm in ansible playbook and
Metodil Nov 14, 2024
576c6aa
comment description in buld and deploy
Metodil Nov 14, 2024
3425b69
move gitleaks test in oun job
Metodil Nov 17, 2024
9717075
ajust ci-pipeline.yaml in trivy test
Metodil Nov 17, 2024
df46c4c
update README.md and add CONTRIBUTING.md
Metodil Nov 17, 2024
754dd52
ajust README.md and CONTRIBUTING.md - new lines ...
Metodil Nov 17, 2024
a01304b
more ajust in README.md
Metodil Nov 17, 2024
f7c4495
final ajustments in README.md
Metodil Nov 17, 2024
1e63cde
add in README.md info for Ansible homework
Metodil Nov 19, 2024
4a3a64c
set trivy ver to 0.20.0
Metodil Nov 21, 2024
9bd147e
set trivy ver to 0.29.0
Metodil Nov 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
#insert_final_newline = true

# Matches multiple files with brace expansion notation
# Set default charset
Expand Down
179 changes: 179 additions & 0 deletions .github/workflows/ci-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
name: u34 ci-pipeline
run-name: u34 ci-pipeline run on ${{ github.event_name }} event
on:
schedule:
- cron: '0 0 * * 1,4' # on Monday (1) and Thursday (4)
pull_request:
# types: [opened, reopened]
# branches:
# - 'main'
# paths:
# - 'app/**'
# - 'Dockerfile'
# - 'requirements.txt'

env:
IMAGE_TAG: metodil/my-hello-app

jobs:

editorconfig:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: editorconfig-checker/action-editorconfig-checker@main
- run: editorconfig-checker

markdown-link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: gaurav-nelson/github-action-markdown-link-check@v1

lint-black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
with:
options: "--check --verbose"
# src: "."

lint-unit-tests:
runs-on: ubuntu-latest
needs: [ editorconfig, markdown-link-check, lint-black ]
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11.8'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov flake8 pylint
- name: Run flake8 linting
run: flake8 app/
- name: Analysing the code with pylint
run: |
pylint --rcfile=.pylintrc $(git ls-files '*.py')
- name: Test with pytest
run: |
cd app
python -m unittest app_test.py

gitleaks-security:
runs-on: ubuntu-latest
needs: lint-unit-tests
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
trivy-security:
runs-on: ubuntu-latest
needs: lint-unit-tests
steps:
- uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@0.20.0
with:
scan-type: 'fs'
ignore-unfixed: true
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif'
# it is link in my github account
# snyk-security:
# runs-on: ubuntu-latest
# needs: lint-unit-tests
# steps:
# - uses: actions/checkout@v4 #actions/checkout@master
# - name: Run Snyk to check for vulnerabilities
# uses: snyk/actions/node@master
# continue-on-error: true # To make sure that SARIF upload gets called
# env:
# SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
# with:
# args: --sarif-file-output=snyk.sarif
# - name: Upload result to GitHub Code Scanning
# uses: github/codeql-action/upload-sarif@v2
# with:
# sarif_file: snyk.sarif
sonarcloud-security:
runs-on: ubuntu-latest
needs: lint-unit-tests
steps:
- uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@v3.1.0 # Ex: v2.1.0, See the latest version at https://github.com/marketplace/actions/sonarcloud-scan
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

build-test:
name: Build image and test
# description: Build Dockerfile, test container with trivy if ok push to registry
runs-on: ubuntu-latest
if: ${{ !cancelled() && !failure() }}
needs: [ gitleaks-security, trivy-security, sonarcloud-security ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build an image from Dockerfile
run: |
docker build -t ${{ env.IMAGE_TAG }}:${{ github.sha }} .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.29.0
with:
image-ref: '${{ env.IMAGE_TAG }}:${{ github.sha }}'
format: 'sarif'
output: 'trivy-results-container.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results-container.sarif'
# if: always()
# with:
# sarif_file: 'trivy-results-container.sarif'

deploy:
name: Get credentials and push to Dockerhub
# description: Get credentials from Hashi vault and push docker image to Dockerhub
runs-on: ubuntu-latest
if: ${{ !cancelled() && !failure() }}
needs: [ build-test ]
steps:
- name: Import Secrets from Hashi vault
id: import-secrets
uses: hashicorp/vault-action@v3
with:
url: https://vault.elcomp68.com:8200
token: ${{ secrets.HV_U34_TOKEN }}
caCertificate: ${{ secrets.VAULT_CA_CERT }}
secrets: |
kv/data/u34-ci dockerhub_username | DOCKERHUB_USERNAME ;
kv/data/u34-ci dockerhub_token | DOCKERHUB_TOKEN ;
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: '${{ env.IMAGE_TAG }}:${{ github.sha }}'
if: success() # Only push if get login is ok
102 changes: 0 additions & 102 deletions .github/workflows/u34-hw.yml

This file was deleted.

14 changes: 14 additions & 0 deletions .gitleaks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Title for the gitleaks configuration file.
title = "Gitleaks title"

# You can include an allowlist table for a single rule to reduce false positives or ignore commits
# with known/rotated secrets
[rules.allowlist]
# note: (rule) regexTarget defaults to check the _Secret_ in the finding.
# if regexTarget is not specified then _Secret_ will be used.
# Acceptable values for regexTarget are "match" and "line"
regexTarget = "match"
regexes = [
'''sonar.organization''',
'''sonar.projectKey''',
]
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-added-large-files
- id: check-json
- id: check-merge-conflict
#- repo: https://github.com/psf/black
# rev: 22.10.0
# hooks:
# - id: black
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.0 # Specify the desired version of Gitleaks
hooks:
- id: gitleaks
8 changes: 8 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[MASTER]
disable=
C0114, # missing-module-docstring
C0115, # missing-class-docstring
C0116, # missing-function-docstring

[MESSAGES CONTROL]
disable=missing-docstring,empty-docstring
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## How to contribute Devops-programe

#### **Did you find a bug?**

* **Open up a GitHub issue if the bug is a security vulnerability**

#### **Did you write a patch that fixes a bug?**

* Open a new GitHub pull request with the patch.

* Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.

#### **Do you intend to add a new feature or change an existing one?**

* Suggest your change in the [my email](mailto:metodil@hotmail.com).

#### **Do you have questions about the source code?**

* Ask any question about how to use on [my email](mailto:metodil@hotmail.com).

Thanks!

Metodi Lichkov
Loading
Loading