AGENT SKILL

html-xss-filtering

暂无简介

License 许可
Apache-2.0
最近更新
2026-11-14
Stars
★ 13
Forks
2

03 SKILL.md 正文

/html-xss-filtering

When to Use

  • Sanitize user-generated HTML with custom allowed tag/attribute rules
  • Strip XSS from web-scraped content before indexing in agent memory
  • Preserve safe formatting (bold, lists) while stripping dangerous attributes
  • Server-side filtering when DOMPurify (browser-oriented) is not preferred

Do NOT use for

  • Scenarios requiring DOM parsing (use [[dompurify-xss-prevention]] with JSDOM)
  • Plain text — stripping is 1 line with replace(/<[^>]*>/g, '')

Custom allowlist config

import xss from 'xss'

const agentXss = new xss.FilterXSS({
  whiteList: {
    a:      ['href', 'title', 'target'],
    b:      [],
    i:      [],
    em:     [],
    strong: [],
    p:      ['class'],
    br:     [],
    ul:     [],
    ol:     [],
    li:     [],
    code:   ['class'],
    pre:    ['class'],
    h1:     [], h2: [], h3: [],
    // Explicitly NOT included: script, style, iframe, object, form, input
  },

  // Strip href with javascript: or data: protocols
  onTagAttr(tag, name, value) {
    if (name === 'href') {
      if (/^javascript:/i.test(value) || /^data:/i.test(value)) {
        return ''  // remove attribute
      }
    }
    return undefined  // use default (allowlist check)
  },

  // Replace unknown tags with escaped text (don't silently drop)
  escapeHtml: xss.escapeHtml,
})

const clean = agentXss.process('<script>alert(1)</script><b>Safe</b>')
// → '&lt;script&gt;alert(1)&lt;/script&gt;<b>Safe</b>'

Strip all HTML (plain text extraction)

const textOnly = new xss.FilterXSS({
  whiteList: {},
  stripIgnoreTag:       true,
  stripIgnoreTagBody:   ['script', 'style'],
})

const text = textOnly.process('<div>Hello <b>World</b><script>bad()</script></div>')
// → 'Hello World'

CSS attribute sanitization

import xss from 'xss'

const withCss = new xss.FilterXSS({
  whiteList: { span: ['style'] },
  css: {
    whiteList: {
      color:      true,
      'font-size': /^\d+(px|em|rem|%)$/,
      // Block: expression(), url(), behavior:
    },
  },
})

Anti-Fake-Pass Checklist

❌ Empty whiteList {} with no stripIgnoreTag → unknown tags preserved, XSS possible
❌ href not validated for protocol → javascript: and data: URIs pass through
❌ css option not set when style attribute allowed → CSS expression() injection
❌ onTagAttr returning null vs undefined → null strips attribute, undefined uses default
❌ Nested quotes in attribute values → some parsers misinterpret, allowing escape
❌ No escaping of tag bodies after strip → raw content may contain partial HTML

04 同仓库更多 Skills

Horonomos-laps
Horonomos-laps/Yana-AI

openai--sentry--sentry

Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

ito-basket-compare

Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

implementing-network-traffic-baselining

Build network traffic baselines from NetFlow/IPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly/daily traffic pattern profiling

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

detecting-evasion-techniques-in-endpoint-logs

Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

implementing-microsegmentation-with-guardicore

Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

ramdisk-tmpfs-patterns

暂无简介

★ 13