Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offer Falco rules json schema to schemastore.org #3432

Open
ctdfo opened this issue Dec 17, 2024 · 5 comments
Open

Offer Falco rules json schema to schemastore.org #3432

ctdfo opened this issue Dec 17, 2024 · 5 comments
Assignees
Milestone

Comments

@ctdfo
Copy link

ctdfo commented Dec 17, 2024

Motivation

We are trying to validate our custom Falco rules but there's no official Falco rules json schema to validate our rules.

Feature

Create an official Falco rules json schema that is available in the schemastore: https://www.schemastore.org/json/

Alternatives

Additional context

This schema already exists: https://github.com/falcosecurity/falco-playground/blob/main/src/components/Editor/falcoSchema.json

  • However it is not compatible with Falco rules for clients since it does not allow the override and it forces overriden rules to still have desc, output and priority
@Issif
Copy link
Member

Issif commented Dec 17, 2024

Hi,

You can get the schema directly from Falco with falco --rule-schema:

{
  "$schema": "http://json-schema.org/draft-06/schema#",
  "definitions": {
    "Alternative": {
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "version": {
          "type": "string"
        }
      },
      "required": [
        "name",
        "version"
      ],
      "title": "Alternative",
      "type": "object"
    },
    "Exception": {
      "additionalProperties": false,
      "properties": {
        "comps": {},
        "fields": {},
        "name": {
          "type": "string"
        },
        "values": {}
      },
      "required": [
        "name",
        "values"
      ],
      "title": "Exception",
      "type": "object"
    },
    "FalcoRule": {
      "additionalProperties": false,
      "properties": {
        "append": {
          "type": "boolean"
        },
        "condition": {
          "type": "string"
        },
        "desc": {
          "type": "string"
        },
        "enabled": {
          "type": "boolean"
        },
        "exceptions": {
          "items": {
            "$ref": "#/definitions/Exception"
          },
          "type": "array"
        },
        "items": {
          "items": {
            "$ref": "#/definitions/Item"
          },
          "type": "array"
        },
        "list": {
          "type": "string"
        },
        "macro": {
          "type": "string"
        },
        "output": {
          "type": "string"
        },
        "override": {
          "$ref": "#/definitions/Override"
        },
        "priority": {
          "$ref": "#/definitions/Priority"
        },
        "required_engine_version": {
          "type": "string"
        },
        "required_plugin_versions": {
          "items": {
            "$ref": "#/definitions/RequiredPluginVersion"
          },
          "type": "array"
        },
        "rule": {
          "type": "string"
        },
        "source": {
          "type": "string"
        },
        "tags": {
          "items": {
            "type": "string"
          },
          "type": "array"
        }
      },
      "required": [],
      "title": "FalcoRule",
      "type": "object"
    },
    "Item": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "string"
        }
      ],
      "title": "Item"
    },
    "OverriddenItem": {
      "enum": [
        "append",
        "replace"
      ],
      "title": "Priority",
      "type": "string"
    },
    "Override": {
      "additionalProperties": false,
      "minProperties": 1,
      "properties": {
        "condition": {
          "$ref": "#/definitions/OverriddenItem"
        },
        "desc": {
          "$ref": "#/definitions/OverriddenItem"
        },
        "enabled": {
          "$ref": "#/definitions/OverriddenItem"
        },
        "exceptions": {
          "$ref": "#/definitions/OverriddenItem"
        },
        "items": {
          "$ref": "#/definitions/OverriddenItem"
        },
        "output": {
          "$ref": "#/definitions/OverriddenItem"
        },
        "priority": {
          "$ref": "#/definitions/OverriddenItem"
        }
      },
      "title": "Override",
      "type": "object"
    },
    "Priority": {
      "enum": [
        "EMERGENCY",
        "ALERT",
        "CRITICAL",
        "ERROR",
        "WARNING",
        "NOTICE",
        "INFO",
        "INFORMATIONAL",
        "DEBUG"
      ],
      "title": "Priority",
      "type": "string"
    },
    "RequiredPluginVersion": {
      "additionalProperties": false,
      "properties": {
        "alternatives": {
          "items": {
            "$ref": "#/definitions/Alternative"
          },
          "type": "array"
        },
        "name": {
          "type": "string"
        },
        "version": {
          "type": "string"
        }
      },
      "required": [
        "name",
        "version"
      ],
      "title": "RequiredPluginVersion",
      "type": "object"
    }
  },
  "items": {
    "$ref": "#/definitions/FalcoRule"
  },
  "type": "array"
}

We need to update the version used by the playground, thanks for this notice cc @LucaGuerra

@ctdfo
Copy link
Author

ctdfo commented Dec 17, 2024

Thank you! That's very useful. Although, it would still be useful if it was available in the schemastore as it can be integrated with most editors.

@leogr
Copy link
Member

leogr commented Dec 20, 2024

Thank you! That's very useful. Although, it would still be useful if it was available in the schemastore as it can be integrated with most editors.

Hey @ctdfo

I appreciate your suggestion. I agree it would be valuable, and I intend to work on it
/assign

🙏

@leogr leogr changed the title Offer falco rules json schema Offer Falco rules json schema to schemastore.org Dec 20, 2024
@leogr
Copy link
Member

leogr commented Dec 20, 2024

Tentatively for
/milestone 0.40.0

@poiana poiana added this to the 0.40.0 milestone Dec 20, 2024
@ctdfo
Copy link
Author

ctdfo commented Dec 20, 2024

Thank you! That's very useful. Although, it would still be useful if it was available in the schemastore as it can be integrated with most editors.

Hey @ctdfo

I appreciate your suggestion. I agree it would be valuable, and I intend to work on it /assign

🙏

Thank you very much! I appreciate it 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants