Skip to content

[Connector-linter]: add VC3xx code checks [3/4]#6291

Merged
jabesq merged 3 commits into
feat/connector-linter-1-foundationfrom
feat/connector-linter-3-code-checks
May 15, 2026
Merged

[Connector-linter]: add VC3xx code checks [3/4]#6291
jabesq merged 3 commits into
feat/connector-linter-1-foundationfrom
feat/connector-linter-3-code-checks

Conversation

@jabesq
Copy link
Copy Markdown
Member

@jabesq jabesq commented Apr 23, 2026

Proposed changes

  • Add VC3xx code quality validation checks (25 files, ~3367 lines)
  • Covers code structure, STIX compliance, import patterns, and best practices

Part 3 of 4 — Stacked on feat/connector-linter-2-config-metadata. Review only the top commit.

Related issues

Checklist

  • I consider the submitted work as finished
  • I have signed my commits using GPG key.
  • I tested the code for its functionality using different use cases
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Further comments

Stacked PR series:

  1. [Connector-linter]: add core linter engine and project scaffold [1/4] #6293: Foundation — scaffold + core engine + README
  2. [Connector-linter]: add VC1xx config and VC2xx metadata checks [2/4] #6292: VC1xx config + VC2xx metadata checks
  3. [Connector-linter]: add VC3xx code checks [3/4] #6291 (this): VC3xx code checks
  4. [Connector-linter]: add VC4xx docker and VC5xx deprecation checks [4/4] #6294: VC4xx docker + VC5xx deprecation checks

@jabesq jabesq requested a review from Copilot April 23, 2026 10:04
@github-actions github-actions Bot added the filigran team use to identify PR from the Filigran team label Apr 23, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@                          Coverage Diff                           @@
##           feat/connector-linter-1-foundation    #6291      +/-   ##
======================================================================
- Coverage                               26.73%   26.73%   -0.01%     
======================================================================
  Files                                    1777     1777              
  Lines                                  104322   104322              
======================================================================
- Hits                                    27892    27891       -1     
- Misses                                  76430    76431       +1     

see 3 files with indirect coverage changes

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jabesq jabesq changed the title feat(connector-linter): add VC3xx code checks [3/4] feat(linter): add VC3xx code checks [3/4] Apr 23, 2026
@jabesq jabesq linked an issue Apr 23, 2026 that may be closed by this pull request
@jabesq jabesq changed the title feat(linter): add VC3xx code checks [3/4] [Connector-linter]: add VC3xx code checks [3/4] Apr 23, 2026
@jabesq jabesq force-pushed the feat/connector-linter-3-code-checks branch from 27ad06d to 58e4362 Compare April 23, 2026 10:09
@jabesq jabesq force-pushed the feat/connector-linter-2-config-metadata branch from f8c5e15 to 2f39cd9 Compare April 23, 2026 10:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds the VC3xx “code quality” ruleset to the shared/connector_linter tool, introducing a set of static checks (regex + AST-based) that validate common connector implementation patterns (author handling, STIX ID determinism, scheduling/work lifecycle, playbook compatibility, etc.).

Changes:

  • Added VC301–VC324 checks implementing code-quality validation for connectors (type-scoped where applicable).
  • Introduced shared VC3xx helper utilities for reading sources and performing AST/regex analyses.
  • Added VC3xx package initializer documenting the new rule catalog.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
shared/connector_linter/connector_linter/checks/vc3xx_code/init.py VC3xx rule catalog / documentation entrypoint.
shared/connector_linter/connector_linter/checks/vc3xx_code/_helpers.py Shared AST/regex/source-loading helpers used across VC3xx checks.
shared/connector_linter/connector_linter/checks/vc3xx_code/vc301_author_defined.py Checks that an author identity is defined.
shared/connector_linter/connector_linter/checks/vc3xx_code/vc302_author_referenced.py Checks that author is referenced on entities (created_by_ref/author kwargs).
shared/connector_linter/connector_linter/checks/vc3xx_code/vc303_connector_type.py Checks CONNECTOR_TYPE is hardcoded (not read from env).
shared/connector_linter/connector_linter/checks/vc3xx_code/vc304_markings_checked.py Checks TLP max enforcement call exists for enrichment connectors.
shared/connector_linter/connector_linter/checks/vc3xx_code/vc305_sdk_base_settings.py Checks connectors-sdk BaseConnectorSettings adoption / legacy config anti-patterns.
shared/connector_linter/connector_linter/checks/vc3xx_code/vc306_log_level_default.py Checks log level defaults to error (advisory).
shared/connector_linter/connector_linter/checks/vc3xx_code/vc307_except_logging.py Warns on low-severity logging as the only log in except blocks.
shared/connector_linter/connector_linter/checks/vc3xx_code/vc308_main_traceback.py Enforces main.py guard + traceback-based error handling.
shared/connector_linter/connector_linter/checks/vc3xx_code/vc309_absolute_imports.py Rejects relative imports in connector source.
shared/connector_linter/connector_linter/checks/vc3xx_code/vc310_external_references.py Prevents spreading default external refs to non-Identity entities.
shared/connector_linter/connector_linter/checks/vc3xx_code/vc311_tlp_markings.py Warns if TLP markings are missing/likely inappropriate based on manifest heuristics.
shared/connector_linter/connector_linter/checks/vc3xx_code/vc312_cleanup_bundle.py Enforces cleanup_inconsistent_bundle=True on send_stix2_bundle calls.
shared/connector_linter/connector_linter/checks/vc3xx_code/vc313_pycti_generate_id.py Enforces explicit id= for stix2 SDO/SRO constructors unless exempted.
shared/connector_linter/connector_linter/checks/vc3xx_code/vc314_auto_backpressure.py Enforces schedule_* usage and flags while True loops for external-import connectors.
shared/connector_linter/connector_linter/checks/vc3xx_code/vc315_work_initiated.py Requires initiate_work (scope currently EXTERNAL_IMPORT).
shared/connector_linter/connector_linter/checks/vc3xx_code/vc316_work_closed.py Requires work closure via to_processed (scope EXTERNAL_IMPORT).
shared/connector_linter/connector_linter/checks/vc3xx_code/vc317_initiate_work_conditional.py Heuristic warning if initiate_work appears unguarded by conditionals.
shared/connector_linter/connector_linter/checks/vc3xx_code/vc318_helper_listen.py Enforces helper.listen() usage for enrichment connectors.
shared/connector_linter/connector_linter/checks/vc3xx_code/vc319_scope_fallback.py Warns if out-of-scope playbook triggers may not return original bundle.
shared/connector_linter/connector_linter/checks/vc3xx_code/vc320_tlp_access_control.py Enforces full TLP access-control flow (extract + check + reject).
shared/connector_linter/connector_linter/checks/vc3xx_code/vc321_playbook_compatible.py Checks playbook_compatible=True and warns if send_stix2_bundle absent.
shared/connector_linter/connector_linter/checks/vc3xx_code/vc322_former_bundle.py Requires reading data['stix_objects'] for enrichment connectors.
shared/connector_linter/connector_linter/checks/vc3xx_code/vc323_helper_listen_stream.py Enforces helper.listen_stream() usage for stream connectors.
shared/connector_linter/connector_linter/checks/vc3xx_code/vc324_relationship_start_stop.py Warns when Relationship sets both start_time and stop_time (perf risk).

@jabesq jabesq force-pushed the feat/connector-linter-2-config-metadata branch from 2f39cd9 to 21f5d13 Compare April 23, 2026 14:59
@jabesq jabesq force-pushed the feat/connector-linter-3-code-checks branch from 58e4362 to 1b2f047 Compare April 23, 2026 14:59
@jabesq jabesq force-pushed the feat/connector-linter-2-config-metadata branch from 21f5d13 to c9e7378 Compare April 23, 2026 15:04
@jabesq jabesq force-pushed the feat/connector-linter-3-code-checks branch 2 times, most recently from 7472997 to f87af77 Compare April 23, 2026 15:15
@jabesq jabesq force-pushed the feat/connector-linter-2-config-metadata branch 2 times, most recently from 6ce204b to 8f91f16 Compare April 23, 2026 16:31
@jabesq jabesq force-pushed the feat/connector-linter-3-code-checks branch 2 times, most recently from 60f90a0 to 0af460b Compare April 24, 2026 08:10
@jabesq jabesq force-pushed the feat/connector-linter-2-config-metadata branch from 8f91f16 to c944093 Compare April 24, 2026 08:12
@jabesq jabesq force-pushed the feat/connector-linter-3-code-checks branch from 0af460b to 7623182 Compare April 24, 2026 08:12
@jabesq jabesq force-pushed the feat/connector-linter-2-config-metadata branch from c944093 to 5d497b6 Compare April 24, 2026 08:16
@jabesq jabesq force-pushed the feat/connector-linter-3-code-checks branch 2 times, most recently from 5bfe52d to 70e89e3 Compare April 24, 2026 08:19
@jabesq jabesq force-pushed the feat/connector-linter-2-config-metadata branch from 5d497b6 to 3adb479 Compare April 24, 2026 08:19
@jabesq jabesq force-pushed the feat/connector-linter-3-code-checks branch from 70e89e3 to 3d79991 Compare April 24, 2026 13:15
@jabesq jabesq force-pushed the feat/connector-linter-2-config-metadata branch 3 times, most recently from acd7987 to 6b60cbd Compare April 30, 2026 14:25
@jabesq jabesq force-pushed the feat/connector-linter-3-code-checks branch from 3d79991 to d6acd47 Compare April 30, 2026 14:25
@jabesq jabesq force-pushed the feat/connector-linter-2-config-metadata branch from 6b60cbd to f3f6af7 Compare April 30, 2026 14:33
@jabesq jabesq force-pushed the feat/connector-linter-3-code-checks branch from d6acd47 to 84090f5 Compare April 30, 2026 14:33
@jabesq jabesq force-pushed the feat/connector-linter-2-config-metadata branch from f3f6af7 to fcf13fd Compare May 5, 2026 15:44
@jabesq jabesq force-pushed the feat/connector-linter-3-code-checks branch from 84090f5 to 4d12e30 Compare May 5, 2026 15:44
Copy link
Copy Markdown
Member

@Powlinett Powlinett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all my comments are blocking but I think we should fix the check of the ID generation (blocking for custom observables) 🙂

return [
CheckFinding(
message="Connector type hardcoded",
severity=Severity.WARNING,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's accepted, should it emit a warning? Why not just info?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning because using the SDK is the best practice, here it is more "legacy but acceptable"

return [
CheckFinding(
message="Connector type hardcoded via Pydantic field",
severity=Severity.WARNING,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's accepted, should it emit a warning? Why not just info?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this check related to the issue we had on Checkfirst? If yes, then the issue occurs even with start_time set only (no need to set both start_time and stop_time).
Maybe instead of checking whether these arguments are set, we could filter relationship types that shouldn't be "time windowed".

@jabesq jabesq force-pushed the feat/connector-linter-3-code-checks branch 2 times, most recently from 46b2e32 to 4aa1e11 Compare May 13, 2026 12:17
@jabesq jabesq force-pushed the feat/connector-linter-2-config-metadata branch from ab3d7fb to efe50de Compare May 13, 2026 12:17
Base automatically changed from feat/connector-linter-2-config-metadata to feat/connector-linter-1-foundation May 15, 2026 08:21
@jabesq jabesq force-pushed the feat/connector-linter-1-foundation branch from 650763f to 3c95b02 Compare May 15, 2026 08:29
@jabesq jabesq force-pushed the feat/connector-linter-3-code-checks branch from 4aa1e11 to 9a8f9af Compare May 15, 2026 08:29
@jabesq jabesq merged commit c930d1c into feat/connector-linter-1-foundation May 15, 2026
125 of 128 checks passed
@jabesq jabesq deleted the feat/connector-linter-3-code-checks branch May 15, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

filigran team use to identify PR from the Filigran team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[all] Create a verification script

4 participants