8000 Security policy, Codecov coverage and README status badges by rafatahmed · Pull Request #133 · rafatahmed/Flahax · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,25 @@ jobs:
- name: Install
run: python -m pip install -e . build
- name: Unit tests
if: matrix.python-version != '3.13'
run: python -m unittest discover -s tests -t .
- name: Unit tests with coverage (coverage is a CI tool only, not a dependency)
if: matrix.python-version == '3.13'
env:
COVERAGE_FILE: build/.coverage
run: |
python -m pip install coverage==7.17.0
mkdir -p build
python -m coverage run --source=src/flahax -m unittest discover -s tests -t .
python -m coverage xml -o build/coverage.xml
python -m coverage report
- uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
if: matrix.python-version == '3.13'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: build/coverage.xml
flags: unittests
fail_ci_if_error: false
- name: Clean wheel and sdist verification
run: python tools/verify_distribution.py
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Security policy (`SECURITY.md`): supported versions, private reporting through GitHub or info@flaha.org, and what counts as a security problem. Coverage: the Python 3.13 CI job runs the tests under `coverage` (a CI tool only, pinned 7.17.0) and uploads the report to Codecov with the pinned `codecov/codecov-action` v7.1.1; `codecov.yml` makes the Codecov checks informational. The README gains Tests, Documentation (Read the Docs) and Codecov badges.
- Code of conduct: the Contributor Covenant 2.1, unchanged apart from the reporting contact (Flaha Agri Tech, info@flaha.org), linked from CONTRIBUTING.
- PEP 8 style and file headers (hardening 3a/4; owner decisions 2026-10-23: line length 99, header template). All Python code is formatted with `ruff format` (PEP 8, 99 columns; quote style kept), which leaves the code's meaning unchanged; one statement per line, PEP 8 spacing and blank lines throughout. Every Python file (161) starts with the header in PEP 8 order: a shebang only on runnable tools and examples, the SPDX copyright and license lines and the disclaimer, then the module docstring (36 test files gained one). `flahax/__init__.py` now lists `__all__` (135 names, unchanged) and `__version__` before its imports, instead of 13 `__all__ +=` lines between them. Unused imports and variables are removed (including an unused H3PO4 term in the phosphate loop; H3PO4 is still in the mass balance), two lambdas assigned to names became functions, and the ambiguous name `l` became `line`. Style settings live in `pyproject.toml` (ruff is a development tool, not a runtime dependency); a new CI `style` job runs `ruff check` and `ruff format --check`, and `tests/test_file_headers.py` checks the header order. Line length is enforced after the remaining long strings and comments are rewrapped (3b). CONTRIBUTING.md documents the conventions.
- Every error code is explained (hardening 2/4). The shipped user guide gains an error code reference: all 91 `DeliveryError` codes, grouped by what you were doing (input values and files, water analysis, products and materials, recipe and pH, chemistry model, stocks and injection, delivery plans and EC), each with its meaning and what to do; 68 were undocumented. `tests/test_error_catalogue.py` fails if a raised code is missing from the guide. A material whose formula cannot be used now says why: it cannot be read (check the brackets and the element symbols), has fractional atoms, does not split into the fertilizer ions FlahaX knows, or splits in more than one way; it said 'give its formula' even when one was given. The exception audit found no other user-facing exception outside `InputError` and `DeliveryError`: the remaining `TypeError`s are argument-type checks, the `AssertionError`s belong to the reference-fixture comparison helper, and the internal `ValueError`s are caught and re-raised.
Expand Down
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Development and release conventions

Everyone who takes part in FlahaX follows the [code of conduct](CODE_OF_CONDUCT.md)
(Contributor Covenant 2.1).
(Contributor Covenant 2.1). Report security problems privately, as
[SECURITY.md](SECURITY.md) explains, not in a public issue.

## Branch names

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ equilibrium chemistry and auditable delivery planning.**
[![PyPI](https://img.shields.io/pypi/v/flahax)](https://pypi.org/project/flahax/)
[![Python](https://img.shields.io/pypi/pyversions/flahax)](https://pypi.org/project/flahax/)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue)](https://github.com/rafatahmed/Flahax/blob/main/LICENSE)
[![Tests](https://github.com/rafatahmed/Flahax/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/rafatahmed/Flahax/actions/workflows/test.yml)
[![Documentation](https://readthedocs.org/projects/flahax/badge/?version=latest)](https://flahax.readthedocs.io/en/latest/)
[![codecov](https://codecov.io/gh/rafatahmed/Flahax/branch/main/graph/badge.svg)](https://codecov.io/gh/rafatahmed/Flahax)
[![PyPI Downloads](https://static.pepy.tech/personalized-badge/flahax?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads)](https://pepy.tech/projects/flahax)

FlahaX turns a crop's nutrient formula and the grower's actual water into a
Expand Down
46 changes: 46 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Security policy

## Supported versions

Security fixes go into the next release and into `main`. Older releases are
not patched; upgrade with `python -m pip install --upgrade flahax`.

| Version | Supported |
|---|---|
| Latest release on PyPI (0.5.x today) | Yes |
| `main` | Yes |
| Earlier releases | No |

## Reporting a vulnerability

Please report security problems privately, not in a public issue:

- through GitHub's private vulnerability reporting on this repository
(**Security** tab, then **Report a vulnerability**), or
- by email to Flaha Agri Tech at <info@flaha.org>, with "FlahaX security" in
the subject.

Include the FlahaX version (`flahax --version`), your Python version and
operating system, the input or steps that show the problem, and what you
expected to happen. You will get an acknowledgement within 7 days and a
plan or a fix as soon as the problem is understood. You will be credited in
the changelog unless you ask not to be.

## What counts as a security problem

FlahaX is a pure-Python library and command line with no runtime
dependencies, no network access and no server. Security problems include:

- code execution, or reading or writing files outside the places FlahaX
is asked to use, through a JSON request, a water analysis, a saved
session or a product file (for example a session name that escapes
`$FLAHAX_HOME`);
- a crafted input that makes FlahaX hang or use unbounded memory;
- a packaged file or release artifact that does not match the source
(the release workflow publishes from tagged commits with pinned actions).

A wrong recipe, pH or acid volume is a correctness bug, not a security
problem: please open a normal issue with the inputs. FlahaX results are
calculations for planning, not dosing instructions; always measure pH and EC
after mixing (see the disclaimer in the README and the Apache-2.0 license,
section 7).
9 changes: 9 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Codecov reports coverage on pull requests; it informs and never blocks a merge.
coverage:
status:
project:
default:
informational: true
patch:
default:
informational: true
Loading
0