Skip to content

Extraction Rules

Rules that extract metadata values from matched components. Defined in the extract block of a detection rule.

Overview

RuleDescription
literalHardcoded value applied to every matched component
fromClassNameExtracts the class name
fromMethodNameExtracts the method name
fromFilePathExtracts a value from the file path using regex capture
fromPropertyExtracts a value from a class property
fromDecoratorArgExtracts a value from a decorator argument
fromDecoratorNameExtracts the decorator name as the value
fromGenericArgExtracts a type name from a generic type argument
fromMethodSignatureExtracts method parameters and return type
fromConstructorParamsExtracts constructor parameter names and types
fromParameterTypeExtracts the type name of a method parameter

Required Fields by Component Type

Component TypeRequired Fields
apiapiType
eventeventName
eventHandlersubscribedEvents
domainOpoperationName
uiroute
useCase(none)

Use --allow-incomplete to emit components with missing fields instead of failing.


literal

Hardcoded value applied to every matched component

Parameters:

FieldTypeRequiredDescription
literalstring | boolean | numberYesThe value to assign

fromClassName

Extracts the class name, optionally with a transform

Parameters:

FieldTypeRequiredDescription
fromClassNametrue | { transform?: Transform }YesUse true for raw name, or object with transform

fromMethodName

Extracts the method name, optionally with a transform

Parameters:

FieldTypeRequiredDescription
fromMethodNametrue | { transform?: Transform }YesUse true for raw name, or object with transform

fromFilePath

Extracts a value from the file path using a regex capture group

Parameters:

FieldTypeRequiredDescription
fromFilePath.patternstringYesRegex pattern with capture groups
fromFilePath.captureintegerYesCapture group index (0 = full match)
fromFilePath.transformTransformNoTransform to apply

fromProperty

Extracts a value from a class property (static or instance)

Parameters:

FieldTypeRequiredDescription
fromProperty.namestringYesProperty name
fromProperty.kind"static" | "instance"YesProperty kind
fromProperty.transformTransformNoTransform to apply

fromDecoratorArg

Extracts a value from a decorator argument by position or name

Parameters:

FieldTypeRequiredDescription
fromDecoratorArg.positionintegerNoArgument index (0-based)
fromDecoratorArg.namestringNoNamed argument key
fromDecoratorArg.transformTransformNoTransform to apply

At least one of position or name is required.


fromDecoratorName

Extracts the decorator name as the value, optionally with a mapping

Parameters:

FieldTypeRequiredDescription
fromDecoratorNametrue | { mapping?: Record<string, string>, transform?: Transform }YesUse true for raw name, or object with mapping/transform

fromGenericArg

Extracts the type name from a generic type argument on an interface or class

Parameters:

FieldTypeRequiredDescription
fromGenericArg.interfacestringYesInterface/class name with the generic parameter
fromGenericArg.positionintegerYesType argument index (0-based)
fromGenericArg.transformTransformNoTransform to apply

fromMethodSignature

Extracts the method's parameter names/types and return type as structured data

Parameters:

FieldTypeRequiredDescription
fromMethodSignaturetrueYesEnables signature extraction

fromConstructorParams

Extracts constructor parameter names and types as structured data

Parameters:

FieldTypeRequiredDescription
fromConstructorParamstrueYesEnables constructor parameter extraction

fromParameterType

Extracts the type name of a method parameter at a given position

Parameters:

FieldTypeRequiredDescription
fromParameterType.positionintegerYesParameter index (0-based)
fromParameterType.transformTransformNoTransform to apply

Transforms

Transforms modify extracted string values.

Transform Order

When combining transforms, they execute in a fixed order regardless of YAML key order: stripSuffixstripPrefixtoLowerCasetoUpperCasekebabToPascalpascalToKebab.

TransformDescription
stripSuffixRemove trailing string
stripPrefixRemove leading string
toLowerCaseLowercase entire string
toUpperCaseUppercase entire string
kebabToPascalConvert kebab-case to PascalCase
pascalToKebabConvert PascalCase to kebab-case

See Also