Suppressions
jnkn.stitching.suppressions
User Suppressions System for jnkn.
This module provides a system for users to suppress false positive matches. Suppressions can be pattern-based (using glob patterns) and have optional expiration dates.
Features: - Glob pattern matching for flexible suppression - YAML-based persistence - Expiration support - Integration with the Stitcher
Storage Location: .jnkn/suppressions.yaml
Classes
Suppression
Bases: BaseModel
A single suppression rule.
Matches source/target pairs using glob patterns.
Source code in src/jnkn/stitching/suppressions.py
Functions
from_dict(data)
classmethod
Create from dictionary (YAML deserialization).
Source code in src/jnkn/stitching/suppressions.py
is_active()
is_expired()
matches(source_id, target_id)
Check if this suppression matches a source/target pair.
Uses glob pattern matching (fnmatch).
Source code in src/jnkn/stitching/suppressions.py
model_post_init(__context)
Generate ID if not provided.
Source code in src/jnkn/stitching/suppressions.py
to_dict()
Convert to dictionary for YAML serialization.
Source code in src/jnkn/stitching/suppressions.py
SuppressionAwareStitcher
Mixin/wrapper for adding suppression awareness to stitching.
This class wraps the Edge creation process to check suppressions.
Source code in src/jnkn/stitching/suppressions.py
Attributes
suppressed_count
property
Number of edges suppressed in current session.
suppressed_edges
property
List of suppressed edges with details.
Functions
__init__(store=None)
Initialize with a suppression store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
SuppressionStore | None
|
SuppressionStore instance (creates default if None) |
None
|
Source code in src/jnkn/stitching/suppressions.py
reset_stats()
should_create_edge(source_id, target_id)
Check if an edge should be created (not suppressed).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_id
|
str
|
Source node ID |
required |
target_id
|
str
|
Target node ID |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if edge should be created |
Source code in src/jnkn/stitching/suppressions.py
SuppressionMatch
dataclass
SuppressionStore
Manages suppression rules with YAML persistence.
Usage
store = SuppressionStore() store.load()
Add suppression
store.add(Suppression( source_pattern="env:HOST", target_pattern="infra:*", reason="HOST is too generic" ))
Check if edge is suppressed
if store.is_suppressed("env:HOST", "infra:main"): print("Suppressed!")
Save changes
store.save()
Source code in src/jnkn/stitching/suppressions.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
Attributes
active_count
property
Number of active (non-expired) suppressions.
count
property
Number of suppressions.
Functions
__init__(path=None)
Initialize the suppression store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | None
|
Path to YAML file. Defaults to .jnkn/suppressions.yaml |
None
|
Source code in src/jnkn/stitching/suppressions.py
add(source_pattern, target_pattern, reason='', created_by='user', expires_at=None)
Add a new suppression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_pattern
|
str
|
Glob pattern for source |
required |
target_pattern
|
str
|
Glob pattern for target |
required |
reason
|
str
|
Why this suppression exists |
''
|
created_by
|
str
|
Who created it |
'user'
|
expires_at
|
datetime | None
|
Optional expiration datetime |
None
|
Returns:
| Type | Description |
|---|---|
Suppression
|
The created Suppression |
Source code in src/jnkn/stitching/suppressions.py
clear_expired()
Remove all expired suppressions.
Returns:
| Type | Description |
|---|---|
int
|
Number of suppressions removed |
Source code in src/jnkn/stitching/suppressions.py
find_matching(source_id, target_id)
Find all suppressions that match a source/target pair.
Useful for debugging why something is/isn't suppressed.
Source code in src/jnkn/stitching/suppressions.py
get_by_id(suppression_id)
Get a suppression by ID.
is_suppressed(source_id, target_id)
Check if an edge should be suppressed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_id
|
str
|
Source node ID |
required |
target_id
|
str
|
Target node ID |
required |
Returns:
| Type | Description |
|---|---|
SuppressionMatch
|
SuppressionMatch with result and details |
Source code in src/jnkn/stitching/suppressions.py
list(include_expired=False)
List all suppressions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_expired
|
bool
|
Whether to include expired suppressions |
False
|
Returns:
| Type | Description |
|---|---|
List[Suppression]
|
List of suppressions |
Source code in src/jnkn/stitching/suppressions.py
load()
Load suppressions from YAML file.
Returns:
| Type | Description |
|---|---|
int
|
Number of suppressions loaded |
Source code in src/jnkn/stitching/suppressions.py
remove(suppression_id)
Remove a suppression by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
suppression_id
|
str
|
ID of suppression to remove |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if removed, False if not found |
Source code in src/jnkn/stitching/suppressions.py
remove_by_index(index)
Remove a suppression by list index (1-based for CLI friendliness).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
1-based index |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if removed |
Source code in src/jnkn/stitching/suppressions.py
save()
Save suppressions to YAML file.
Returns:
| Type | Description |
|---|---|
bool
|
True if successful |
Source code in src/jnkn/stitching/suppressions.py
Functions
create_default_store(path=None)
Create a SuppressionStore and load from disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | None
|
Optional path to YAML file |
None
|
Returns:
| Type | Description |
|---|---|
SuppressionStore
|
Initialized SuppressionStore |