Skip to content

[LFX] Rule Testing Framework: Filesystem Mocking for Git Ingestion #6552

Description

@krrish175-byte

Part of the rule testing framework implementation (parent issue: #6503).

Goal

Provide a way for test authors to mock the local filesystem during rule evaluation. This is necessary to test rules that rely on the git ingester, which clones a repository and evaluates its files (e.g., checking for specific .github/workflows/ configurations).

Scope

  • Introduce a mechanism in the Starlark testing environment (e.g., a mock_fs dictionary) to allow users to define file paths and their contents.
  • Integrate the mocked filesystem into the evaluation engine so that the git ingester reads from the mocked files instead of attempting to clone or read from the real local filesystem.
  • Add unit tests to verify that rules using the git ingester can successfully evaluate the mocked filesystem.

Context

As discussed in previous PRs, we have successfully implemented HTTP mocking for the rest ingester. However, the git ingester currently lacks a corresponding mocking layer, meaning test authors cannot verify rules that depend on file contents.

Acceptance Criteria

  • Test authors can specify a mock filesystem structure within their *.star test scripts.
  • The engine correctly intercepts file reads from the git ingester and returns the mocked contents.
  • Un-mocked file reads are handled gracefully (e.g., returning an appropriate error or falling back safely).
  • Comprehensive unit tests are added for the filesystem mocking layer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions