security-rule-development
БесплатноБез исполняемых скриптовНе проверенAdding or changing rules for b2c security scan (the SDK security module). Use when adding a new security rule, tuning a rule's false positives or negatives…
от SalesforceCommerceCloud★ 58 звёзд на GitHubОб этом скилле
Security Rule Development
Security rules live in packages/b2c-tooling-sdk/src/security/. Each rule is an ESLint v9 rule, so the same object runs in three places: the SDK runner (used by b2c security scan, MCP, and the VS Code extension), ESLint, and oxlint's JS plugins. Tests run every rule under all three.
Add a rule
Create
src/security/rules/<rule-id>.tswithdefineScriptRule:import {defineScriptRule} from '../rule.js'; import {isRequestDerived, propertyName} from '../script/helpers.js'; export default defineScriptRule({ id: 'my-rule', // kebab-case, no slashes; a public contract once released severity: 'medium', // critical | high | medium | low | info confidence: 'medium', // how sure a finding is real; low = needs human or agent judgment category: 'injection', // see SecurityCategory in types.ts cwe: ['CWE-79'], description: 'One sentence: what the rule finds.', remediation: 'How to fix a finding.', create(context) { return { CallExpression(node) { if (propertyName(node.callee) === 'writeRaw' && isRequestDerived(node.arguments[0], context.sourceCode)) { context.report({node, message: 'Specific, actionable message.'}); } }, }; }, });Register it in
src/security/rules/index.ts(SCRIPT_RULES).Add fixtures in
test/security/fixtures/<rule-id>/. Every.jsfile under the directory is a fixture:- End every line that should produce a finding with
// expect. The finding's start line must be the marked line. - Files without markers must produce no findings. Include the safe versions and near-misses the rule must not flag.
- Single-file rules use
bad.jsandgood.js. Cross-file rules add aproject/tree with cartridges (folders with a.projectfile) and aproject/project.jsonof{"cartridgePath": [...]}; the harness builds the project index from the rule's directory and passes it to every runner. - Base fixtures on real storefront code where possible (SFRA, SiteGenesis, Storefront Next cartridges). The reference storefronts are not assumed to be clean: judge findings there on their merits.
- End every line that should produce a finding with
Document it with a
## <rule-id>section indocs/guide/security-rules.md(severity, confidence, CWE, what it finds, a finding/fix example) and a row in the table at the top. Regenerate the tooling index (pnpm --filter @salesforce/b2c-tooling-sdk run generate:tooling-index).Update the user skill fix table in
skills/b2c-cli/skills/b2c-security/SKILL.md.Run
pnpm --filter @salesforce/b2c-tooling-sdk exec mocha "test/security/**/*.test.ts". The harness checks the ID format, fixtures, docs section, and that the SDK runner, ESLint, and oxlint all report exactly the marked lines.Add a changeset (
@salesforce/b2c-tooling-sdkand@salesforce/b2c-cli, minor for a new rule).
Metadata rules
Rules over site import/export data live in src/security/metadata/rules/ and are registered in METADATA_RULES. They don't run in ESLint or oxlint, but share findings, suppressions, baselines, and SARIF with script rules.
import {defineMetadataRule} from '../types.js';
import {childNamed, descendantsNamed} from '../xml.js';
export const myRule = defineMetadataRule({
id: 'service-something',
severity: 'medium',
confidence: 'high',
category: 'config',
cwe: ['CWE-16'],
description: 'What it finds.',
remediation: 'How to fix it.',
kinds: ['services'], // services | preferences | metadata | csrf-allowlist | ocapi-settings
check(document, report) {
if (document.format !== 'xml') return;
for (const service of descendantsNamed(document.root, 'service')) {
const flag = childNamed(service, 'some-flag');
if (flag?.text === 'true') report({line: flag.line, column: flag.column, message: '...'});
}
},
});
- XML elements have local
name,attributes, trimmedtext,line,column, andchildren. JSON documents (OCAPI settings) havedataandtext; locate lines withjsonKeyLines(text, key, value). - To read a new file kind, add its XML root element (or file name rule) to
detectMetadataKind()insrc/security/metadata/run.ts. - Fixtures go in
test/security/fixtures/<rule-id>/bad/andgood/with real file names (services.xml,wapi_shop_config.json). Mark XML lines with<!-- expect -->at the end of the line; for JSON, list expected line numbers in a sidecar<file>.expect.
Rule API: what you may use
Rules must run identically in all three runners, so stick to this subset:
- Visitors keyed by ESTree node type, plus
'<Type>:exit'. No selector syntax (CallExpression > Identifier). node.parent(set on every node).context.report({node, message}). NomessageId,data,fix, orsuggest.context.sourceCode.getText(node),.getScope(node),.getAncestors(node),.ast,.text.- `context.
Установить security-rule-development в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл security-rule-development?
Adding or changing rules for b2c security scan (the SDK security module). Use when adding a new security rule, tuning a rule's false positives or negatives from a real-world case, writing rule fixtures, or changing the rule runner, suppressions, baselines, or SARIF output.
Как установить скилл security-rule-development?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл security-rule-development запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic