garc-gws-agent-runtime/lib/audit.sh
林 駿甫 (Shunsuke Hayashi) 7b5951a1d5 fix: resolve all 17 playbook findings (P0–P3)
P0 fixes:
- agent register: upsert by agent_id (no duplicate rows)
- daemon poll-once: extract _gmail_poll_cycle, run synchronously
- garc_core.py: suppress urllib3/googleapiclient DeprecationWarnings

P1 fixes:
- OAuth: detect RefreshError → delete stale token → re-auth flow
- OAuth: scope coverage check before returning valid creds
- ingress: add stale-reset subcommand (reset in_progress > N min)
- sheets: trim-sheet / clean-all — deleteDimension for empty rows
- approval gate: send Gmail notification to GARC_APPROVAL_EMAIL

P2 additions:
- Google Chat: garc-chat-helper.py + garc send chat subcommands
- Service Account: garc auth service-account verify + DWD support
- Audit log: Sheets audit tab + garc audit list + bin/garc async hook
- garc auth revoke: POST /revoke + delete token file
- kg: pagination fix, shell injection fix, garc-kg-query.py
- docs: _doc_insert_text / append_doc / garc drive append-doc

P3 additions:
- Multi-tenant: lib/profile.sh (list/use/add/show/remove/current)
  bin/garc: auto-load profile config.env and token.json
- Google Forms pipeline: garc-forms-helper.py + lib/forms.sh
  garc forms list/responses/watch
- systemd: _daemon_install_service OS-detect → launchd or systemd units
- Python version gate (>=3.10) in bin/garc + pyproject.toml
- garc doctor command for environment diagnostics

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-15 09:55:33 +09:00

47 lines
1 KiB
Bash

#!/usr/bin/env bash
# GARC audit.sh — Audit log viewer
# Events are appended to the 'audit' tab in Google Sheets by bin/garc.
garc_audit() {
local subcommand="${1:-list}"
shift || true
case "${subcommand}" in
list) _audit_list "$@" ;;
*)
cat <<EOF
Usage: garc audit <subcommand>
Subcommands:
list [--agent <id>] [--since YYYY-MM-DD] [--format table|json]
Show audit log from Google Sheets
EOF
return 1
;;
esac
}
_audit_list() {
local sheets_id="${GARC_SHEETS_ID:-}"
local agent_id="" since="" fmt="table"
while [[ $# -gt 0 ]]; do
case "$1" in
--agent|-a) agent_id="$2"; shift 2 ;;
--since|-s) since="$2"; shift 2 ;;
--format|-f) fmt="$2"; shift 2 ;;
*) shift ;;
esac
done
if [[ -z "${sheets_id}" ]]; then
echo "Error: GARC_SHEETS_ID not set" >&2
return 1
fi
python3 "${GARC_DIR}/scripts/garc-sheets-helper.py" audit-list \
--sheets-id "${sheets_id}" \
${agent_id:+--agent-id "${agent_id}"} \
${since:+--since "${since}"} \
--format "${fmt}"
}