Repository navigation
Crons tab actions: run, pause, resume and schedule - #228
Conversation
Reviewer's GuideData structuresExtend cron scan records with launchd targeting metadata and owned-job schedule information, and populate those fields during manifest merging and launchd scanning.
APIExpose the cron action CLI forms and register the new verbs and web action route.
ImplementationImplement scan-validated launchd actions locally and over SSH, plus locked schedule edits to the declaring config followed by cron apply.
UIAdd action controls and owned-job schedule editing to cron detail rows, with styles for the controls and schedule field.
DocumentationDocument the new CLI verbs, Crons tab actions, targeting and scheduling behavior, and the narrowed read-only guarantee.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Hey - I've found 1 security issue, and 5 other issues
Security issues:
- Detected non-static command inside Command. Audit the input to 'exec.Command'. If unverified user data can reach this call site, this is a code injection vulnerability. A malicious actor can inject a malicious script to execute arbitrary code. (link)
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="internal/app/crons_actions.go" line_range="206" />
<code_context>
+ if err != nil {
+ return "", err
+ }
+ if err := writeFileReplacing(path, string(data)); err != nil {
+ return "", err
+ }
</code_context>
<issue_to_address>
**Private configs become readable**
When a schedule is edited in a config with permissions stricter than 0644, `writeFileReplacing` creates the replacement with mode `0644` and renames it over the original, so other local users can read previously private config contents, including secrets.
Preserve the original file permissions when creating the replacement.
</issue_to_address>
### Comment 2
<location path="internal/app/crons_actions.go" line_range="206" />
<code_context>
+ if err != nil {
+ return "", err
+ }
+ if err := writeFileReplacing(path, string(data)); err != nil {
+ return "", err
+ }
</code_context>
<issue_to_address>
**Concurrent edits lose config changes**
When a config save or schedule edit overlaps another write to the same config, `setOwnedCronSchedule` writes a YAML document it read earlier, so a concurrent config save or schedule edit can overwrite the other change; separate processes can also collide on the same `.tmp` path and make a write fail.
Coordinate all writers across processes and use a unique temporary file for each write.
</issue_to_address>
### Comment 3
<location path="internal/app/crons_actions.go" line_range="37" />
<code_context>
+const launchdActionScript = `d="gui/$(id -u)"
+case "$1" in
+run) launchctl kickstart "$d/$2" ;;
+pause) launchctl disable "$d/$2" && { launchctl bootout "$d/$2" 2>/dev/null || true; } ;;
+resume) launchctl enable "$d/$2" && { launchctl print "$d/$2" >/dev/null 2>&1 || launchctl bootstrap "$d" "$3"; } ;;
+*) echo "unknown action: $1" >&2; exit 2 ;;
</code_context>
<issue_to_address>
**Paused jobs keep running**
When `launchctl disable` succeeds but `launchctl bootout` fails while the job is still loaded, `launchdActionScript` suppresses the `bootout` error, so `runLaunchdAction` reports success and the view reports the job paused even though it remains loaded and can keep running.
Return the `bootout` failure unless the job is already unloaded.
</issue_to_address>
### Comment 4
<location path="internal/app/crons_actions.go" line_range="192-193" />
<code_context>
+ if err != nil {
+ return "", err
+ }
+ if node == nil {
+ path = shared
+ if root, node, err = cronScheduleNode(path, id); err != nil {
+ return "", err
</code_context>
<issue_to_address>
**Schedule edits miss local overrides**
When a local overlay contains the job ID but omits its schedule while the shared config declares it, `setOwnedCronSchedule` falls back to editing the shared entry, but `loadCronsManifest` lets the local entry override it. The effective schedule remains unset, so `cron apply` rejects the edit or omits and can remove the installed job.
Edit or complete the local entry that overrides the shared job instead of editing the shared entry.
</issue_to_address>
### Comment 5
<location path="internal/app/app.go" line_range="572-573" />
<code_context>
" tackroom hook remove [--dry-run] [--agents ...] <query>",
" tackroom cron collect [--hosts local,HOST...] [--table] [--config PATH]",
" tackroom cron apply [--dry-run] [--config PATH]",
+ " tackroom cron run|pause|resume [--host HOST] [--config PATH] ID",
+ " tackroom cron schedule [--config PATH] ID \"MIN HOUR DOM MON DOW\"",
}
</code_context>
<issue_to_address>
**Action commands missing from quick references**
When the new cron action CLI verbs are added while the README and skill command lists remain unchanged, the CLI help and Crons documentation list the new action verbs, but the README and skill quick-reference still list only `collect` and `apply`, so users following those references won't find the new commands.
Add the new cron action forms to the README and skill command lists, keeping the public command references consistent.
Also at `docs/crons.md:117-118`.
</issue_to_address>
### Comment 6
<location path="internal/app/crons_actions.go" line_range="215" />
<code_context>
out, err := exec.CommandContext(ctx, exe, "cron", "apply", "--config", shared).CombinedOutput()
</code_context>
<issue_to_address>
**security (go.lang.security.audit.dangerous-exec-command):** Detected non-static command inside Command. Audit the input to 'exec.Command'. If unverified user data can reach this call site, this is a code injection vulnerability. A malicious actor can inject a malicious script to execute arbitrary code.
*Source: opengrep*
</issue_to_address>Sourcery assessment
Needs a human reviewer. 6 findings to address first, and a run action can execute an existing job immediately, and a schedule change is written to config and applied to launchd, so a wrong action or schedule can trigger job effects that persist beyond reverting this code. Reverting would remove the controls, but it cannot undo a run or any effects the job already produced.
Blocking findings: internal/app/crons_actions.go:206, internal/app/crons_actions.go:206, internal/app/crons_actions.go:37, internal/app/crons_actions.go:193, internal/app/app.go:573, and 1 more
…try; pause fails if the job stays loaded
The Crons tab could only report. This adds the actions people kept doing by hand with
launchctlandcron apply.What changes
unit,plist,ownedanddeclared_schedule.docs/crons.mdgains a "View actions" section; the non-goal that said the view never changes a job is narrowed.How it acts
stale_cronsotherwise; CLI: collects that host first). Label and plist path come from the scan, never from the request.launchctl kickstart. Pause:disable+bootout, so it stays off across logins and shows asdisabled. Resume:enable+bootstrapwhen not loaded. Remote hosts get the same script throughssh -o BatchMode=yes HOST sh -s, with every argument single-quoted.apply, written tocrons.jobs.<id>.schedulein the file that declares the job (local overlay first), thencron apply. A paused owned job must be resumed first.authorizeAPI(..., true)CSRF and origin check.Verified
go build,go vet,go test ./internal/app/pass.x-researchwith its current expression: manifest rewritten,cron applyreports up to date, plist unchanged.tackroom.local.yaml: comments and flow lists kept; one blank line dropped.Not covered
not_scanned. That is existing collect behavior, not changed here.Summary by Sourcery
Enable controlled launchd job management from the Crons view and command line while keeping other scheduler types read-only.
New Features:
Enhancements:
Documentation: