Skip to content

Commit 6e69f37

Browse files
committed
powerplatform-check: read Power Pages, canvas app and flow exports
Semgrep reads Power Platform exports as plain YAML and JSON and finds nothing, and the reasoning pass only reads Python, PHP and JavaScript handlers, so a repository holding a Power Pages site, canvas apps and flows came back with no code findings at all. New engine lib/powerplatform_check.py, run like the Mule check when the tree holds a table-permissions folder, a .pa.yaml or .fx.yaml file, or a flow definition. Every rule keys on the export format, never on a repository's own names: - Global table permissions held by the Anonymous Users role (read, write or delete is high with the Web API on; create is medium), and Global write for the Authenticated Users role. Web roles, permissions and Webapi site settings are joined, and a FetchXML filter lowers a grade. - HTTP triggered flows anybody can call that write or send mail and never read the request headers. - HTML email bodies built from record or caller values, recipients taken from a caller, and CSV tables with no formula neutralizing. - Canvas HtmlText formulas that join data into markup without EncodeHTML. Date named columns and Text(value, format) are not counted. Checked against a real export (every outside finding reproduced, plus 11 it missed) and against six unrelated repositories on 13 branches, with no false alarms.
1 parent 29304c7 commit 6e69f37

4 files changed

Lines changed: 671 additions & 0 deletions

File tree

‎lib/code_analysis.sh‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,17 @@ code_languages() {
445445
# reads them.
446446
find "$dir" -type d \( -name .git -o -name node_modules -o -name target \) -prune -o \
447447
-type f -path '*/src/main/mule/*.xml' -print -quit 2>/dev/null | grep -q . && langs+=" mule"
448+
# Power Platform exports: Power Pages site metadata, canvas app source and
449+
# flow definitions. Nothing else here knows what any of it means.
450+
find "$dir" -type d \( -name .git -o -name node_modules \) -prune -o \
451+
-type f \( -name '*.tablepermission.yml' -o -name '*.pa.yaml' -o -name '*.fx.yaml' \
452+
-o -path '*/table-permissions/*.yml' \) -print -quit 2>/dev/null \
453+
| grep -q . && langs+=" powerplatform"
454+
if [[ "$langs" != *powerplatform* ]] && grep -rlq --include='*.json' \
455+
--exclude-dir=.git --exclude-dir=node_modules \
456+
-e 'workflowdefinition.json' "$dir" 2>/dev/null; then
457+
langs+=" powerplatform"
458+
fi
448459
printf '%s' "${langs# }"
449460
}
450461

@@ -468,6 +479,27 @@ run_mule_check() {
468479
fi
469480
}
470481

482+
# run_powerplatform_check <dir> <full_name> <branch> <web> -> findings JSON
483+
#
484+
# Power Pages table permissions and web roles, canvas app HtmlText formulas and
485+
# Power Automate flow definitions. Semgrep reads them as plain YAML and JSON
486+
# and finds nothing. See lib/powerplatform_check.py.
487+
run_powerplatform_check() {
488+
local dir="$1" repo="$2" branch="$3" web="$4"
489+
cfg_bool '.scan.code_analysis.powerplatform_check' true || { echo '[]'; return 0; }
490+
local python; python=$(ghscan_venv_bin python3 2>/dev/null || command -v python3 || true)
491+
[[ -n "$python" ]] || { log_debug "no python, so Power Platform exports are not read"; echo '[]'; return 0; }
492+
local out; out=$(tmp_file ppcheck)
493+
with_timeout 300 "$python" -I "$GHSCAN_HOME/lib/powerplatform_check.py" "$dir" "$repo" "$branch" \
494+
"$web" "$(provider_link_parts)" > "$out" 2>"$GHSCAN_TMPROOT/ppcheck.log" || true
495+
if jq -e 'type == "array"' "$out" >/dev/null 2>&1; then
496+
cat "$out"
497+
else
498+
log_warn "[$repo] the Power Platform check did not run: $(tail -1 "$GHSCAN_TMPROOT/ppcheck.log" 2>/dev/null)"
499+
echo '[]'
500+
fi
501+
}
502+
471503
# run_gosec <dir> <full_name> -> findings JSON
472504
run_gosec() {
473505
local dir="$1" repo="$2" branch="$3" web="$4"

0 commit comments

Comments
 (0)