Skip to content

Commit e970b5e

Browse files
jerr0328sinanislekdemirragecryxtatiana14
authored
🎉 Initial MVP (#3)
* [wip] Setup initial project structure - Add pyproject.toml with ruff and setuptools config - Add schema file with some initial enums - Add initial requirements-dev.txt (not pinned/hashed for now to avoid noise) - Add core audit log fields (type, timestamp, level, version) - Add demo output with `python -m audit_log.log` * Add support for headers parsing * Complete audit logging initial API Co-authored-by: Sinan ISLEKDEMIR <sinan@islekdemir.com> Co-authored-by: George Koutsikos <ragecryx@users.noreply.github.com> * Add pre-commit hooks * Enforce principal by dataclass (#1) * Enforce principal by dataclass * Fix for the broken ruff state and type * Update audit_log/log.py Co-authored-by: Jeremy Mayeres <1524722+jerr0328@users.noreply.github.com> * Add import * Better ruff config * Remove JWT processing (#2) * Remove JWT processing * Rebase from enforce principal * Fix type_ * Change hte logic to JWT first --------- Co-authored-by: Jeremy Mayeres <1524722+jerr0328@users.noreply.github.com> * Wrap exceptions with common base exception * Change version to integer * add unit tests (#4) * add unit tests * fix PR comments * Add case-insensitive support * add workflow for lint and unit tests (#5) * add workflow for lint and unit tests * fix * add pythonpath * add python 3.11 for test job * update workflow * Prepare for public release * Address mypy issue * Add security file and codeowners * Add release workflow * Cleanup, improve comments --------- Co-authored-by: Sinan ISLEKDEMIR <sinan@islekdemir.com> Co-authored-by: George Koutsikos <ragecryx@users.noreply.github.com> Co-authored-by: Tatiana Smirnova <tatiana.smirnova@iceye.fi> Co-authored-by: Sinan Islekdemir <sinan.islekdemir@iceye.fi>
1 parent f8d8cdf commit e970b5e

19 files changed

Lines changed: 678 additions & 0 deletions

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @iceye-ltd/role-python-logging-maintainer

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: monday
9+
time: "09:00"
10+
timezone: "Europe/Helsinki"
11+
commit-message:
12+
prefix: "⬆️"

.github/workflows/pre-commit.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: pre-commit
3+
4+
"on":
5+
pull_request:
6+
push:
7+
branches: [main]
8+
9+
jobs:
10+
pre-commit:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 5
13+
steps:
14+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
15+
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
16+
with:
17+
python-version: "3.12"
18+
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1

.github/workflows/release.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: Upload Python Package
3+
4+
"on":
5+
release:
6+
types: [created]
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
environment: release
12+
permissions:
13+
# IMPORTANT: this permission is mandatory for trusted publishing
14+
id-token: write
15+
steps:
16+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
17+
- name: Set up Python
18+
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
19+
with:
20+
python-version: "3.12"
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install -r requirements-dev.txt
25+
- name: Build
26+
run: python -m build
27+
- name: Publish package distributions to PyPI
28+
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14

.github/workflows/test.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: Test
3+
4+
"on":
5+
pull_request:
6+
push:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 15
17+
strategy:
18+
matrix:
19+
python-version: ["3.11", "3.12"]
20+
21+
steps:
22+
- name: Checkout the code
23+
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
24+
with:
25+
# Need fetch-depth 0 for generating version based on tags/commits since tag
26+
fetch-depth: 0
27+
28+
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
32+
- name: Install Deps
33+
run: make setup
34+
35+
- name: Lint
36+
run: make lint
37+
38+
- name: Run tests
39+
run: make test

.pre-commit-config.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
default_language_version:
4+
python: python3
5+
repos:
6+
- repo: https://github.com/pre-commit/pre-commit-hooks
7+
rev: v4.6.0
8+
hooks:
9+
- id: trailing-whitespace
10+
- id: check-json
11+
- id: check-yaml
12+
- id: check-merge-conflict
13+
- id: check-toml
14+
- id: end-of-file-fixer
15+
- id: mixed-line-ending
16+
args: ["--fix=lf"]
17+
- id: file-contents-sorter
18+
files: ^requirements-dev.txt$
19+
- repo: https://github.com/charliermarsh/ruff-pre-commit
20+
# Ruff version.
21+
rev: v0.4.3
22+
hooks:
23+
- id: ruff
24+
args: [ --fix, --exit-non-zero-on-fix ]
25+
- repo: https://github.com/psf/black-pre-commit-mirror
26+
rev: 24.4.2
27+
hooks:
28+
- id: black

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Iceye Oy
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
SHELL := bash
2+
3+
PYTHONPATH = .
4+
5+
.PHONY: test
6+
test:
7+
PYTHONPATH=. pytest --cov=audit_log -vv tests
8+
9+
10+
.PHONY: fmt
11+
fmt: ## Format the source code using pre-commit hooks
12+
pre-commit run --all-files
13+
14+
15+
.PHONY: setup
16+
setup: ## Install project dependencies from requirements-dev.txt
17+
pip install -r requirements-dev.txt
18+
19+
20+
.PHONY: lint
21+
lint:
22+
ruff check .
23+
mypy audit_log

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
11
# python-audit-log
2+
23
Audit logging library for Python
4+
5+
## Usage
6+
7+
`pip install iceye-audit-log`
8+
9+
Then in your applications:
10+
11+
`from audit_log.log import log`
12+
13+
And invoke it with the proper arguments.
14+
15+
## Contributing
16+
17+
This project is mostly for internal use, however it is made public as the concept of audit logging is quite generic.
18+
We are careful about accepting contributions and those would have to align with our needs.
19+
Reviews and issues will be considered time-permitting.

SECURITY.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Security Policy
2+
3+
## Responsible Disclosure
4+
5+
If you think you've found a security vulnerability, please adhere to responsible
6+
disclosure practices by allowing us a reasonable time to investigate and address
7+
the issue before making any information public.
8+
9+
## Reporting a Vulnerability
10+
11+
Please report security issues by sending email to: <security_reports@iceye.fi>.
12+
Try to be as explicit as possible, describing all the steps and example code to
13+
reproduce the issue.
14+
15+
The ICEYE security team will review the issue and get back to you.

0 commit comments

Comments
 (0)