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
29 changes: 5 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,10 @@ jobs:

# ponytail: pandas + requests only. vllm/torch need a GPU and multi-GB wheels,
# and every experiment needs assets/CVEfixes.db, which is not in the repo.
- run: pip install pandas requests
- run: pip install pandas requests pytest ruff

- name: Compile all sources
run: python -m compileall -q .
- name: Lint (syntax errors and undefined names)
run: ruff check --select E9,F63,F7,F82 *.py tests

- name: Prompt library renders
run: |
python -c "
from prompts_kat import promptS1, promptR1, promptD1
p = promptS1('int f(){}', 'Out-of-bounds Write')
assert 'int f(){}' in p and 'Out-of-bounds Write' in p, p
assert promptD1('x', 'Use After Free', 'desc').count('desc') == 1
assert 'Out-of-bounds Write' in promptR1('int f(){}', 'Out-of-bounds Write')
"

- name: Paired scoring is correct
run: |
python -c "
import pandas as pd
from utils import calculate_metrics
df = pd.DataFrame({'pred_before': [1, 0, -1], 'pred_after': [1, 0, -1]})
assert calculate_metrics(df, 'pred_before', 'pred_after') == (1, 1, 1, 1, 1, 1)
"

- name: Notebooks are valid JSON
run: python -c "import json,glob; [json.load(open(f)) for f in glob.glob('*.ipynb')]"
- name: Smoke tests
run: pytest -q
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ kat_*/
assets/
__pycache__/
tmp/
.DS_Store
.venv/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Euisuh Jeong

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ print(calculate_metrics(df, 'pred_before', 'pred_after')) # (tp, fp, tn, fn, na
"
```

Both snippets run with only `pandas` installed — no GPU, no database. They are what CI executes on every push.
Both snippets run with only `pandas` installed — no GPU, no database. The same checks run as `pytest` (`tests/test_smoke.py`) in CI on every push, plus a `ruff` lint for syntax errors and undefined names.

## Example workflow

Expand Down Expand Up @@ -236,3 +236,7 @@ C++ pairs were extracted (`CVEFixes_c++.csv`) but were not tabulated per CWE.
of the original run, kept so the published `S2` numbers stay reproducible.
- **Evaluated models are 7–8B open weights** (llama3, codeQwen, deepSeekCoder, artigenz) at temperature 0; results
do not speak to larger or frontier models.

## License

MIT, see [`LICENSE`](LICENSE). The CVEfixes data is distributed separately under its own terms.
28 changes: 28 additions & 0 deletions tests/test_smoke.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import json
import pathlib
import sys

import pandas as pd

ROOT = pathlib.Path(__file__).resolve().parent.parent
sys.path.insert(0, str(ROOT))

from prompts_kat import promptD1, promptR1, promptS1 # noqa: E402
from utils import calculate_metrics # noqa: E402


def test_prompts_render():
p = promptS1("int f(){}", "Out-of-bounds Write")
assert "int f(){}" in p and "Out-of-bounds Write" in p
assert promptD1("x", "Use After Free", "desc").count("desc") == 1
assert "Out-of-bounds Write" in promptR1("int f(){}", "Out-of-bounds Write")


def test_paired_scoring():
df = pd.DataFrame({"pred_before": [1, 0, -1], "pred_after": [1, 0, -1]})
assert calculate_metrics(df, "pred_before", "pred_after") == (1, 1, 1, 1, 1, 1)


def test_notebooks_are_valid_json():
for f in ROOT.glob("*.ipynb"):
json.loads(f.read_text())
Loading