@hivemagnus/magnus-skills 2.9.1 → 2.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hivemagnus/magnus-skills",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.1",
|
|
4
4
|
"description": "Ubuntu operations skill catalogue for Magnus and Hermes Agent: package, service, network, storage and security runbooks with validated manifests.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"magnus",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# backup-manager — Backup files/directories with integrity verification
|
|
3
3
|
set -euo pipefail
|
|
4
|
+
# Archives of /etc hold password hashes and private keys: never leave them readable by other accounts.
|
|
5
|
+
umask 077
|
|
4
6
|
|
|
5
7
|
VERBOSE=0
|
|
6
8
|
SRC="/etc"
|
|
@@ -57,6 +59,10 @@ done
|
|
|
57
59
|
[[ $# -ge 1 ]] && SRC="$1"
|
|
58
60
|
[[ $# -ge 2 ]] && DEST="$2"
|
|
59
61
|
[[ $# -ge 3 ]] && RETENTION_DAYS="$3"
|
|
62
|
+
if ! [[ "$RETENTION_DAYS" =~ ^[0-9]{1,5}$ ]]; then
|
|
63
|
+
echo "RETENTION_DAYS must be a whole number of days" >&2
|
|
64
|
+
exit 2
|
|
65
|
+
fi
|
|
60
66
|
|
|
61
67
|
echo "=== Backup Manager ==="
|
|
62
68
|
echo "Source: $SRC"
|
|
@@ -100,7 +106,8 @@ if [[ $VERBOSE -ge 1 ]]; then
|
|
|
100
106
|
fi
|
|
101
107
|
|
|
102
108
|
echo "--- Retention Cleanup ---"
|
|
103
|
-
|
|
109
|
+
# Only this tool's own archives directly in DEST, never matching files in directories below it.
|
|
110
|
+
DELETED=$(find "$DEST" -maxdepth 1 -type f -name "backup-*.tar.gz" -mtime +"$RETENTION_DAYS" -delete -print | wc -l)
|
|
104
111
|
echo "Purged $DELETED old backup(s) (> ${RETENTION_DAYS} days)"
|
|
105
112
|
|
|
106
113
|
echo "--- Current Backups ---"
|
|
@@ -62,6 +62,12 @@ echo "=== News Reporter ==="
|
|
|
62
62
|
: "${NEWS_CATEGORY:=general}"
|
|
63
63
|
: "${NEWS_PAGE_SIZE:=10}"
|
|
64
64
|
|
|
65
|
+
# These values become URL parameters: accept only what the API defines.
|
|
66
|
+
[[ "${NEWS_COUNTRY}" =~ ^[a-z]{2}$ ]] || { echo "ERROR: NEWS_COUNTRY must be a two-letter country code" >&2; exit 2; }
|
|
67
|
+
[[ "${NEWS_CATEGORY}" =~ ^[a-z]{1,32}$ ]] || { echo "ERROR: NEWS_CATEGORY must be a lowercase word" >&2; exit 2; }
|
|
68
|
+
[[ "${NEWS_PAGE_SIZE}" =~ ^[0-9]{1,3}$ ]] || { echo "ERROR: NEWS_PAGE_SIZE must be a number" >&2; exit 2; }
|
|
69
|
+
[[ "${NEWSAPI_KEY}" =~ ^[A-Za-z0-9_-]{8,128}$ ]] || { echo "ERROR: NEWSAPI_KEY has an unexpected format" >&2; exit 2; }
|
|
70
|
+
|
|
65
71
|
NODE_NAME="$(hostname)"
|
|
66
72
|
DATE_STAMP="$(date +%Y-%m-%d)"
|
|
67
73
|
TIME_STAMP="$(date +%H%M%S)"
|
|
@@ -80,16 +86,18 @@ mkdir -p "${REPORT_DIR}" "${RAW_DIR}"
|
|
|
80
86
|
|
|
81
87
|
# ── Fetch headlines from NewsAPI ──
|
|
82
88
|
echo "--- Fetching Headlines ---"
|
|
83
|
-
API_URL="https://newsapi.org/v2/top-headlines?country=${NEWS_COUNTRY}&category=${NEWS_CATEGORY}&pageSize=${NEWS_PAGE_SIZE}
|
|
89
|
+
API_URL="https://newsapi.org/v2/top-headlines?country=${NEWS_COUNTRY}&category=${NEWS_CATEGORY}&pageSize=${NEWS_PAGE_SIZE}"
|
|
84
90
|
|
|
85
|
-
|
|
91
|
+
# The key goes in a header read from stdin, so it is never in the process list or the URL.
|
|
92
|
+
HTTP_CODE=$(printf 'X-Api-Key: %s\n' "${NEWSAPI_KEY}" | curl -s --max-time 30 -H @- -o "${RAW_DIR}/response.json" -w "%{http_code}" "${API_URL}" 2>/dev/null) || {
|
|
86
93
|
echo "ERROR: Failed to reach NewsAPI"
|
|
87
94
|
exit 1
|
|
88
95
|
}
|
|
89
96
|
|
|
90
97
|
if [[ "${HTTP_CODE}" != "200" ]]; then
|
|
91
98
|
echo "ERROR: NewsAPI returned HTTP ${HTTP_CODE}"
|
|
92
|
-
|
|
99
|
+
# The error body is remote text: show only its filtered message.
|
|
100
|
+
jq -r '.message // empty' "${RAW_DIR}/response.json" 2>/dev/null | "${SCRIPT_DIR}/prompt-filter.sh" || true
|
|
93
101
|
exit 1
|
|
94
102
|
fi
|
|
95
103
|
|
|
@@ -127,10 +135,15 @@ for i in $(seq 0 $((ARTICLE_COUNT - 1))); do
|
|
|
127
135
|
CONTENT=$(jq -r ".articles[${i}].content // \"\"" "${RAW_DIR}/response.json")
|
|
128
136
|
|
|
129
137
|
# Sanitize each field through the prompt injection filter
|
|
130
|
-
TITLE=$(
|
|
131
|
-
DESCRIPTION=$(
|
|
132
|
-
CONTENT=$(
|
|
133
|
-
AUTHOR=$(
|
|
138
|
+
TITLE=$(printf '%s\n' "${TITLE}" | "${SCRIPT_DIR}/prompt-filter.sh")
|
|
139
|
+
DESCRIPTION=$(printf '%s\n' "${DESCRIPTION}" | "${SCRIPT_DIR}/prompt-filter.sh")
|
|
140
|
+
CONTENT=$(printf '%s\n' "${CONTENT}" | "${SCRIPT_DIR}/prompt-filter.sh")
|
|
141
|
+
AUTHOR=$(printf '%s\n' "${AUTHOR}" | "${SCRIPT_DIR}/prompt-filter.sh")
|
|
142
|
+
# Every remote field is filtered, not only the long ones.
|
|
143
|
+
SOURCE=$(printf '%s\n' "${SOURCE}" | "${SCRIPT_DIR}/prompt-filter.sh")
|
|
144
|
+
[[ "${PUBLISHED}" =~ ^[0-9TZ:.+-]{1,40}$ ]] || PUBLISHED=""
|
|
145
|
+
# A link target that could close the Markdown link and carry text is dropped.
|
|
146
|
+
[[ "${URL}" =~ ^https?://[^[:space:]\(\)\<\>\"]{1,2000}$ ]] || URL=""
|
|
134
147
|
|
|
135
148
|
{
|
|
136
149
|
echo "## $((i + 1)). ${TITLE}"
|