T09 · Insecure Skill Coding Practices
- Location
scripts/mdnew_to_mdx.sh:18- Finding
Untrusted Remote Content Is Written Directly to an Executable MDX File
- Content
View full analysis
"$raw_file" awk 'BEGIN{p=0} /^Markdown Content:/{p=1; next} p{print}' "$raw_file" > "$body_file" src_title="" src_description="" if awk 'NR==1{exit ($0=="---" ? 0 : 1)}' "$body_file"; then src_title="$(awk 'BEGIN{inside=0} /^---$/{if(inside==0){inside=1; next}else{exit}} inside && /^title:[[:space:]]/{sub(/^title:[[:space:]]*/, ""); print; exit}' "$body_file")" src_description="$(awk 'BEGIN{inside=0} /^---$/{if(inside==0){inside=1; next}else{exit}} inside && /^description:[[:space:]]/{sub(/^description:[[:space:]]*/, ""); print; exit}' "$body_file")" fi if [ -z "$src_title" ]; then src_title="Official Doc" fi if [ -z "$src_description" ]; then src_description="Converted from docs via markdown.new" fi awk ' BEGIN { in_fm=0 } NR==1 && $0=="---" { in_fm=1; next } in_fm && $0=="---" { in_fm=0; next } in_fm { next } { if ($0 ~ /^\[Skip to main content\]/) next if ($0 ~ /^\[\]\(https:\/\/[^)]*\)\[Docs\]\(\/home\)$/) next if ($0 ~ /^Copy as Markdown$/) next if ($0 ~ /^Copied!$/) next if ($0 ~ /^On this page$/) next if ($0 ~ /^[[:space:]]*\* \[[^]]+\]\(#[^)]+\)[[:space:]]*$/) next line=$0 gsub(/\[\]\(#[^)]+ "Direct link to [^"]+"\)/, "", line) print line } ' "$body_file" > "$content_file" awk ' { if ($0 ~ /^[[:space:]]*$/) { blank++; if (blank <= 1) print ""; next } blank=0; print } ' "$content_file" > "$clean_file" mkdir -p "$(dirname "$out_file")" { echo "---" echo "title: ${src_title}" echo "description: ${src_description}" echo "sourceUrl: ${source_url}" echo "retrievedAt: ${retrieved_at}" echo "---" echo cat "$clean_file" } > "$out_file" echo "Wrote ${out_file}" ``` ### Technical Analysis The script accepts an arbitrary source string wi ...[truncated 2884 chars]- Remediation
View remediation
