wake.detectors.api
module
#
DetectorConfidence
class
#
Bases: StrEnum
The confidence of a DetectorResult.
Source code in wake/detectors/api.py
DetectorImpact
class
#
Bases: StrEnum
The impact of a DetectorResult.
Source code in wake/detectors/api.py
Detection
class
#
A single detection bound to a location in the source code through an IR node. May contain any number of subdetections.
Attributes:
Name | Type | Description |
---|---|---|
ir_node |
IrAbc
|
IR node representing the detection. |
message |
str
|
User-friendly message describing the detection. |
subdetections |
Tuple[Detection, ...]
|
Subdetections of this detection. |
lsp_range |
Optional[Tuple[int, int]]
|
Byte offsets (start, end) of the detection used for highlighting in LSP diagnostics and in SARIF export. |
subdetections_mandatory |
bool
|
Whether the detection requires at least one subdetection to be valid, or if the subdetections are not mandatory for the existence of the detection. This attribute determines whether the detection should be filtered out if all subdetections are filtered out based on the detectors ignore_paths configuration. |
Source code in wake/detectors/api.py
DetectorResult
class
#
A single result reported by a Detector.
Attributes:
Name | Type | Description |
---|---|---|
detection |
Detection
|
Detection describing the location in the source code and the message. |
impact |
DetectorImpact
|
Impact of the detection. |
confidence |
DetectorConfidence
|
Confidence of the detection. |
uri |
Optional[str]
|
Optional URI to a page describing the detection. |
Source code in wake/detectors/api.py
Detector
class
#
Bases: Visitor
Base class for detectors.
Attributes:
Name | Type | Description |
---|---|---|
paths |
List[Path]
|
Paths the detector should operate on. May be empty if a user did not specify any paths, e.g. when running |
extra |
Dict[Any, Any]
|
Extra data shared between all detectors in a single run. May contain additional data set by the execution engine. |
Source code in wake/detectors/api.py
visit_mode: Literal['paths', 'all']
property
#
Configurable visit mode of the detector. If set to paths
, the detector visit_
methods will be called only for the paths specified by the user.
If set to all
, the detector visit_
methods will be called for all paths, leaving the filtering of detections to the detector implementation.
In this case, the detector should use the paths
attribute to determine which paths to operate on.
Returns:
Type | Description |
---|---|
Literal['paths', 'all']
|
Visit mode of the detector. |
detect()
abstractmethod
#
Abstract method that must be implemented in a detector to return the discovered detections.
Returns:
Type | Description |
---|---|
List[DetectorResult]
|
List of detector results. |