-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from coreruleset/refactor/add-tests
refactor: add tests as pytests
- Loading branch information
Showing
12 changed files
with
653 additions
and
448 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# For most projects, this workflow file will not need changing; you simply need | ||
# to commit it to your repository. | ||
# | ||
# You may wish to alter this file to override the set of languages analyzed, | ||
# or to provide custom queries or build logic. | ||
# | ||
name: "CodeQL" | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
# The branches below must be a subset of the branches above | ||
branches: [ "master" ] | ||
schedule: | ||
- cron: '18 7 * * 5' | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: [ 'python' ] | ||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] | ||
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
# Initializes the CodeQL tools for scanning. | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v3 | ||
with: | ||
languages: ${{ matrix.language }} | ||
# If you wish to specify custom queries, you can do so here or in a config file. | ||
# By default, queries listed here will override any specified in a config file. | ||
# Prefix the list here with "+" to use these queries and those in the config file. | ||
|
||
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs | ||
# queries: security-extended,security-and-quality | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Publish to PyPI | ||
on: | ||
release: | ||
types: [published] | ||
workflow_dispatch: | ||
inputs: | ||
publish: | ||
description: "Publish to pypi.org? (will not work from forks!)" | ||
required: false | ||
default: 'false' | ||
|
||
jobs: | ||
test: | ||
name: Test Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Publish to pypi | ||
uses: coveooss/[email protected] | ||
with: | ||
project-name: secrules-parsing | ||
pypi-token: ${{ secrets.PYPI_TOKEN }} | ||
pre-release: ${{ github.ref != 'refs/heads/master' }} | ||
dry-run: ${{ github.ref != 'refs/heads/master' && github.event.inputs.publish != 'true' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
name: Regression Tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
regression: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
crs-version: ['4.10.0'] | ||
python-version: ['3.9', '3.10', '3.11', '3.12'] | ||
|
||
steps: | ||
- name: "Checkout repo" | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install uv | ||
uses: astral-sh/setup-uv@v5 | ||
with: | ||
enable-cache: true | ||
cache-dependency-glob: "uv.lock" | ||
|
||
- name: Set up Python 3 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
uv sync --all-extras --dev | ||
- name: "Run unit tests" | ||
run: | | ||
uv run pytest -vs | ||
- name: "Run crs linter tests for ${{ matrix.crs-version }}" | ||
run: | | ||
curl -SLs https://github.com/coreruleset/coreruleset/archive/refs/tags/v${{ matrix.crs-version }}.tar.gz -o - | \ | ||
tar xzvf - --strip-components=1 --wildcards "*/rules/*" --wildcards "*/crs-setup.conf.example" --wildcards "*/util/APPROVED_TAGS" | ||
uv run crs-linter --output=github -r crs-setup.conf.example -r rules/*.conf -t util/APPROVED_TAGS -v ${{ matrix.crs-version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[project] | ||
name = "crs-linter" | ||
version = "0.1.0" | ||
description = "CRS linter" | ||
authors = [ | ||
{name = "Ervin Hegedus", email = "[email protected]"} | ||
] | ||
requires-python = ">=3.9" | ||
license = "Apache-2.0" | ||
readme = "README.md" | ||
Issues = "https://github.com/coreruleset/crs-linter/issues" | ||
Homepage = "https://github.com/coreruleset/crs-linter" | ||
Repository = "https://github.com/coreruleset/crs-linter.git" | ||
|
||
keywords = ["OWASP", "CRS", "linter"] | ||
|
||
classifiers = [ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: Apache Software License", | ||
"Operating System :: OS Independent", | ||
] | ||
|
||
packages = [ | ||
{ include = "crs_linter", from = "src" } | ||
] | ||
|
||
# Requirements | ||
dependencies = [ | ||
"msc_pyparser >=1.2.1" | ||
] | ||
|
||
[project.scripts] | ||
crs-linter = 'crs_linter.cli:main' | ||
|
||
[dependency-groups] | ||
dev = [ | ||
"pytest >=8.1.1,<9" | ||
] | ||
|
||
[tool.semantic_release] | ||
version_variable = "pyproject.toml:version" | ||
|
||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
This file was deleted.
Oops, something went wrong.
Empty file.
Oops, something went wrong.