Compare commits
1 commit
318910265e
...
dbabc262d9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dbabc262d9 |
1 changed files with 27 additions and 0 deletions
27
lib/env.sh
27
lib/env.sh
|
|
@ -232,6 +232,33 @@ forge_api_all() {
|
||||||
printf '%s' "$all_items"
|
printf '%s' "$all_items"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# DIRECT CURL API CALLS WITH URL VALIDATION
|
||||||
|
# =============================================================================
|
||||||
|
# These helpers provide a consistent way to make authenticated API calls
|
||||||
|
# with URL validation to prevent injection attacks.
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
# forge_api_call - Direct curl call with URL validation
|
||||||
|
# Usage: forge_api_call "GET /issues" [extra_args...]
|
||||||
|
forge_api_call() {
|
||||||
|
local url="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
# Validate FORGE_API to prevent URL injection
|
||||||
|
if ! validate_url "$FORGE_API"; then
|
||||||
|
echo "ERROR: FORGE_API validation failed - possible URL injection attempt" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl -sf -X "${url%% *}" \
|
||||||
|
-H "Authorization: token ${FORGE_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
"${FORGE_API}${url#* }" "$@"
|
||||||
|
}
|
||||||
|
# Backwards-compat alias
|
||||||
|
codeberg_api_all() { forge_api_all "$@"; }
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# WOODPECKER API HELPER
|
# WOODPECKER API HELPER
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue