Skip to content

No validation performed to check parameters for a trigger type match what is defined by user #3453

@lakshmi-kannan

Description

@lakshmi-kannan

See https://github.com/StackStorm/st2/pull/3398/files#r120671893.

To repro:

Declare a trigger type in sensor YAML like so

---
  class_name: "FileWatchSensor"
  enabled: true
  entry_point: "file_watch_sensor.py"
  description: "Sensor which monitors files for new lines"
  trigger_types:
    -
      name: "file_watch.line"
      pack: "linux"
      description: "Trigger which indicates a new line has been detected"
      # This sensor can be supplied a path to a file to tail via a rule.
      parameters_schema:
        type: "object"
        properties:
          file_path:  # User ``st2`` should have permissions to be able to read this file.
            description: "Path to the file to monitor"
            type: "string"
            required: true
        additionalProperties: false

Now try to register a rule which doesn't confirm to the schema for parameters we defined in sensor YAML like so

---
name: sample_rule_file_watch
pack: "examples"
description: Sample rule custom trigger type - add a file to be watched by file_watch_sensor in linux pack.
enabled: true

trigger:
  parameters:
    iam_messing_up: /tmp/st2_test
  type: linux.file_watch.line

criteria: {}

action:
  parameters:
    cmd: echo "{{trigger}}"
  ref: core.local

You'll see that a trigger is created and rule will register successfully both of which shouldn't happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions