feat: Add SHZ log inspection and HighGo database querying capabilities

- Introduced `inspect-shz-logs` skill for inspecting local and production logs with bounded read-only commands.
- Added `view.sh` script for log viewing with options for following logs and filtering by keywords.
- Created `query-shz-highgo` skill for querying the SHZ HighGo database through an SSH gateway.
- Implemented read-only SQL execution with strict controls on allowed statements and query structure.
- Added new domain and mapper classes for managing outdoor fair job associations.
- Enhanced `OutdoorFairController` to support job listing and management for outdoor fairs.
- Created SQL scripts for initializing outdoor fair job data and managing menu visibility.
This commit is contained in:
2026-06-25 23:13:35 +08:00
parent c24f5e6621
commit 82d3264c72
18 changed files with 781 additions and 4 deletions

View File

@@ -0,0 +1 @@
Hello@2026

View File

@@ -0,0 +1,42 @@
---
name: query-shz-highgo
description: Query the SHZ HighGo Security Enterprise Edition database through its SSH gateway using a guarded read-only psql workflow. Use when Claude Code is working in the shz-backend project and needs to inspect database schemas, tables, columns, row counts, or application data; diagnose data-related behavior; or execute SELECT, WITH, SHOW, or EXPLAIN statements against the project's HighGo database.
---
# Query SHZ HighGo
Use the bundled script to run read-only SQL through the configured SSH gateway.
## Query workflow
1. Form the narrowest useful query. Add a small `LIMIT` when inspecting rows.
2. For unfamiliar tables, inspect `information_schema.columns` before selecting business data.
3. Run:
```bash
.claude/skills/query-shz-highgo/scripts/query.sh 'SELECT current_database(), current_user, current_schema()'
```
4. Summarize the result and distinguish returned facts from inferences.
The script accepts only statements beginning with `SELECT`, `WITH`, `SHOW`, or `EXPLAIN`, rejects multiple statements, sets `search_path` to `shz,public`, enforces database-level read-only mode, and applies a 30-second timeout. Never bypass these controls or perform writes unless the user explicitly requests a separate write-capable workflow.
## Schema discovery
List user tables:
```bash
.claude/skills/query-shz-highgo/scripts/query.sh "SELECT table_schema, table_name FROM information_schema.tables WHERE table_schema NOT IN ('pg_catalog', 'information_schema') ORDER BY 1, 2"
```
Inspect columns:
```bash
.claude/skills/query-shz-highgo/scripts/query.sh "SELECT column_name, data_type, is_nullable FROM information_schema.columns WHERE table_schema = 'shz' AND table_name = 'lowercase_table_name' ORDER BY ordinal_position"
```
HighGo may expose unquoted identifiers in lowercase and quoted identifiers with exact case. Query `information_schema` first when the spelling is uncertain.
## Connection details
Read [references/connection.md](references/connection.md) only when troubleshooting connectivity or updating the endpoint. Do not print, quote, or expose the password file.

View File

@@ -0,0 +1,12 @@
# Connection reference
- SSH gateway: `root@124.243.245.42`
- HighGo client: `/opt/HighGo4.5.7-see/bin/psql`
- Database endpoint: `39.98.44.136:6023`
- Database: `highgo`
- User: `sysdba`
- Default schemas: `shz,public`
- Detected server: HighGo Security Enterprise Edition Database System 4.5.10
- Password source: `../.password`, mode `600`; override with `HIGHGO_PASSWORD_FILE`
The SSH gateway must be reachable with the workstation's existing SSH key. Keep credentials out of commands, logs, responses, and `SKILL.md`.

View File

@@ -0,0 +1,43 @@
#!/usr/bin/env bash
set -euo pipefail
skill_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
password_file="${HIGHGO_PASSWORD_FILE:-$skill_dir/.password}"
ssh_host="root@124.243.245.42"
psql_path="/opt/HighGo4.5.7-see/bin/psql"
db_host="39.98.44.136"
db_port="6023"
db_name="highgo"
db_user="sysdba"
if [[ ! -r "$password_file" ]]; then
echo "HighGo password file is missing or unreadable: $password_file" >&2
exit 2
fi
if [[ $# -eq 0 ]]; then
echo "Usage: $0 'SELECT ...'" >&2
exit 2
fi
sql="$*"
if [[ ! "$sql" =~ ^[[:space:]]*(SELECT|select|WITH|with|SHOW|show|EXPLAIN|explain)([[:space:]]|$) ]]; then
echo "Rejected: only SELECT, WITH, SHOW, and EXPLAIN queries are allowed." >&2
exit 3
fi
sql_without_final_semicolon="${sql%;}"
if [[ "$sql_without_final_semicolon" == *';'* ]]; then
echo "Rejected: multiple SQL statements are not allowed." >&2
exit 3
fi
password="$(<"$password_file")"
sql_base64="$(printf '%s' "$sql" | base64 | tr -d '\n')"
{
printf '%s\n' "$password"
printf '%s\n' "$sql_base64"
} | ssh -o BatchMode=yes -o ConnectTimeout=10 "$ssh_host" \
"read -r PGPASSWORD; read -r SQL_BASE64; export PGPASSWORD; export PGOPTIONS='-c default_transaction_read_only=on -c search_path=shz,public -c statement_timeout=30000'; SQL=\$(printf '%s' \"\$SQL_BASE64\" | base64 -d); exec '$psql_path' -X --no-psqlrc -h '$db_host' -p '$db_port' -U '$db_user' -d '$db_name' -v ON_ERROR_STOP=1 -P pager=off -c \"\$SQL\""