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/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: ffpdf CodeQL config

# security-extended: broader security queries than the default suite; the right
# bar for a parser that eats untrusted input.
queries:
- uses: security-extended

query-filters:
# cpp/path-injection flags every fopen() of a path the user passed on the
# command line. For a CLI whose entire job is reading the files named in
# argv, that is the interface, not a vulnerability -- there is no trust
# boundary between "user input" and "the file the user asked to open".
# This rule fired on ~every PR that adds a file-opening path (dismissed on
# alerts 4-8, 10-15), so it is excluded here rather than dismissed each time.
# If ffpdf ever accepts a path from genuinely untrusted input (e.g. a field
# value that names an external file), revisit this exclusion.
- exclude:
id: cpp/path-injection
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
with:
languages: c-cpp
build-mode: manual
# security-extended: broader security queries than the default suite;
# right bar for a parser that eats untrusted input.
queries: security-extended
# Query suite (security-extended) and the cpp/path-injection exclusion
# live in the config file.
config-file: ./.github/codeql/codeql-config.yml

- name: Build
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ fuzz-findings/
FUTURE_WORK.md
filled.pdf
answers.fdf
values.json
out/
row.fdf
35 changes: 33 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- `fields` command: list every fillable field as JSON, with names, types,
current values (UTF-16 values decoded to UTF-8), choice options and
- `fields` command: list every fillable field as JSON, with names,
human-readable labels (`/TU`), types, current values (UTF-16 values decoded
to UTF-8), `required`/`readonly`/`maxlen` constraints, choice options and
combo/multi-select flags, and checkbox on-state names. A machine-readable
companion to `fdf-extract` for scripts and AI agents.

- `fill --json` writes a machine-readable result to stdout (the `updated`
and `not_found` field names and their counts; requires `-o` for the PDF),
and `fill --strict` exits 3 if any FDF field did not match a form field.
For scripts and AI agents that need to verify a fill by exit code or
parsed output rather than scraping stderr.
- Documented that multi-select choice fields are filled with an array,
`/V [(opt1) (opt2)]`.
- `fill` now accepts a **JSON** values object as well as an FDF, auto-detected
from the file's content, and takes the PDF and values file in **either
order** (`-` reads the values from stdin). JSON values may be a string, a
multi-select array, a number, or a boolean (to check/clear a checkbox). This
closes the discover-then-fill loop in one format for agents. The documented
argument order is now `fill <pdf> <values>`.
- Radio-button groups: `fields` now reports the group's valid option names,
and `fill` sets the selected button's appearance state (`/AS`) so the choice
renders, not just the group value.

### Changed

- `fill` now exits **2** (and writes no output) when no field in the input
matched the form. A no-op fill — e.g. every field name misspelled — is
treated as a failure by default rather than a silent success, so callers
need no flag to detect it. `--flatten` is exempt (it removes the form even
with no new values), and a partial match (some fields land) still exits 0
unless `--strict` is given.

- A value longer than a text field's `/MaxLen` is now truncated to fit (on a
UTF-8 character boundary) with a warning, instead of writing an over-length,
non-conformant value; `fill --json` lists such fields under `truncated`.

### Fixed

- ffpdf can now re-read PDFs it filled. Streams without a `/Filter` (legal
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ docs/demo.gif: docs/demo.tape docs/demo-form.pdf $(TARGET)
{ echo "vhs not found -- install it (and ttyd + ffmpeg): https://github.com/charmbracelet/vhs"; exit 1; }
vhs docs/demo.tape

docs/demo-batch.gif: docs/demo-batch.tape docs/demo-template.fdf docs/demo-customers.csv docs/demo-form.pdf $(TARGET)
docs/demo-batch.gif: docs/demo-batch.tape docs/demo-template.json docs/demo-customers.csv docs/demo-form.pdf $(TARGET)
@command -v vhs >/dev/null || \
{ echo "vhs not found -- install it (and ttyd + ffmpeg): https://github.com/charmbracelet/vhs"; exit 1; }
vhs docs/demo-batch.tape
Expand Down
Loading
Loading