Skip to content

Commit 58cba99

Browse files
docs: Document language compliance scanner and logging helpers (#144)
Add Julia docstrings for openat and private_log covering arguments, resource ownership, permissions, path and file validation, and failure side effects. Expand check_repo documentation to explain output, counter updates, return status, and possible early termination under set -e. Validation: Inspected the pinned diff and function implementations. Tests were not run; changes are documentation only. [View coding task](https://app.coderabbit.ai/code/tasks/1d987cef-a1e5-558e-afff-28ab696248db?source=coding_agent_github_pr_description) Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent d026a7e commit 58cba99

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

‎check-language-compliance-log.jl‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,34 @@
55
using Base.Filesystem: JL_O_RDONLY, JL_O_WRONLY, JL_O_CREAT, JL_O_DIRECTORY,
66
JL_O_NOFOLLOW, JL_O_NONBLOCK, JL_O_CLOEXEC
77

8+
"""
9+
Open `name` relative to directory descriptor `dirfd` using POSIX `flags` and
10+
return a file descriptor that the caller must close. Absolute names ignore
11+
`dirfd`. When creating a file, `mode` specifies permissions subject to the umask.
12+
Throw a `SystemError` if the operating system rejects the open.
13+
"""
814
function openat(dirfd, name, flags, mode=0o600)
915
result = ccall(:openat, Cint, (Cint, Cstring, Cint, Cuint), dirfd, name, flags, mode)
1016
Base.systemerror("openat $name", result == -1)
1117
return result
1218
end
1319

20+
"""
21+
Create or truncate a private report and return a writable stream for the caller
22+
to close. `state_dir` is the full, absolute report directory, normally ending in
23+
`scripts/language-compliance`; `log_name` uses eight digits followed by `.log`
24+
(the calendar date is not validated).
25+
26+
Create missing directories with mode `0700`, subject to the umask, and set the
27+
final directory to `0700`. Reject `.` and `..` components and directory symlinks;
28+
the final three directory components must belong to the invoking user. The log
29+
must be a regular file owned by that user with one hard link, and must not be a
30+
symlink. Set its mode to `0600` and truncate it only after validation.
31+
32+
Throw on invalid arguments or unsafe paths/files, and propagate errors from
33+
opening, inspecting, changing permissions or truncating. Directory creation and
34+
permission changes may remain after failure; no fallback log is returned.
35+
"""
1436
function private_log(state_dir, log_name)
1537
isabspath(state_dir) || error("state directory must be absolute")
1638
occursin(r"^[0-9]{8}\.log$", log_name) || error("invalid log name")

‎check-language-compliance.sh‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ FFI_VIOLATIONS=0
3030
COMPLIANT_REPOS=0
3131
TOTAL_REPOS=0
3232

33-
# Check a single repository
33+
# Scan repository directory $1 recursively for potential API/ABI/FFI language
34+
# violations and print the findings to stdout. Update API_VIOLATIONS,
35+
# ABI_VIOLATIONS, FFI_VIOLATIONS, COMPLIANT_REPOS and TOTAL_REPOS in the current
36+
# shell; initialise these counters before calling. A completed call returns the
37+
# final echo's status, not a compliance result. With set -e active, incrementing
38+
# a zero counter returns status 1 and can terminate the scan early.
3439
check_repo() {
3540
local repo_path="$1"
3641
local repo_name="$(basename "$repo_path")"

0 commit comments

Comments
 (0)