> ## Documentation Index
> Fetch the complete documentation index at: https://kosli-mbevc1-patch-1.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# kosli evaluate input

> [BETA] Evaluate a local JSON input against a Rego policy.

## Synopsis

```shell theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
kosli evaluate input [flags]
```

\[BETA] Evaluate a local JSON input against a Rego policy.
Read JSON from a file or stdin and evaluate it against a Rego policy.
The input file should contain the raw JSON object your policy expects —
not the wrapper produced by `--show-input`. Use `jq '.input'` to extract
the policy input from a `--show-input --output json` capture.

The policy must use `package policy` and define an `allow` rule.
An optional `violations` rule (a set of strings) can provide human-readable denial reasons.

By default a deny exits with code 1. Pass `--no-assert` to print the verdict
and exit 0 even on deny, when this command is feeding another tool as a
policy decision point.

When `--input-file` is omitted, JSON is read from stdin.

Use `--params` to pass configuration data to the policy as `data.params`.
This accepts inline JSON or a file reference (`@file.json`).

## Flags

| Flag                        | Description                                                                                                                                        |
| :-------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--assert`                  | \[optional] Exit with a non-zero status when the policy denies. This is the current default; pass `--assert` to lock it in across future releases. |
| `-h`, `--help`              | help for input                                                                                                                                     |
| `-i`, `--input-file` string | \[optional] Path to a JSON input file. Reads from stdin if omitted.                                                                                |
| `--no-assert`               | \[optional] Print the result and always exit 0, even when the policy denies. Use when this command feeds another tool as a policy decision point.  |
| `-o`, `--output` string     | \[defaulted] The format of the output. Valid formats are: \[table, json]. (default "table")                                                        |
| `--params` string           | \[optional] Policy parameters as inline JSON or @file.json. Available in policies as data.params.                                                  |
| `-p`, `--policy` string     | Path or http(s):// URL of a Rego policy to evaluate against the input.                                                                             |
| `--show-input`              | \[optional] Include the policy input data in the output.                                                                                           |

## Flags inherited from parent commands

| Flag                          | Description                                                                                                                                             |
| :---------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `-a`, `--api-token` string    | The Kosli API token.                                                                                                                                    |
| `-c`, `--config-file` string  | \[optional] The Kosli config file path. (default "kosli")                                                                                               |
| `--debug`                     | \[optional] Print debug logs to stdout.                                                                                                                 |
| `-H`, `--host` string         | \[defaulted] The Kosli endpoint. (default "[https://app.kosli.com](https://app.kosli.com)")                                                             |
| `--http-proxy` string         | \[optional] The HTTP proxy URL including protocol and port number. e.g. `http://proxy-server-ip:proxy-port`                                             |
| `-r`, `--max-api-retries` int | \[defaulted] How many times should API calls be retried when the API host is not reachable. (default 3)                                                 |
| `--org` string                | The Kosli organization.                                                                                                                                 |
| `-q`, `--quiet`               | \[optional] Suppress non-critical warning messages. Errors and normal output are not affected. If both `--quiet` and `--debug` are set, `--debug` wins. |

## Live Examples in different CI systems

<Tabs>
  <Tab title="GitHub">
    View an example of the `kosli evaluate input` command in GitHub.

    In [this YAML file](https://github.com/cyber-dojo/snyk-scanning/blob/00c479764cb9eca038fdaaaef108672d0bb0ed26/tests/test_rego_rules.sh#L272)
  </Tab>
</Tabs>

## Examples Use Cases

These examples all assume that the flags  `--api-token`, `--org`, `--host`, (and `--flow`, `--trail` when required), are [set/provided](/getting_started/install/#assigning-flags-via-environment-variables).

<AccordionGroup>
  <Accordion title="capture trail data for local policy iteration">
    ```shell theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
    kosli evaluate trail TRAIL --flow FLOW 
    	--policy allow-all.rego 
    	--show-input --output json | jq '.input' > trail-data.json

    ```
  </Accordion>

  <Accordion title="then iterate on your policy locally">
    ```shell theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
    kosli evaluate input 
    	--input-file trail-data.json 
    	--policy policy.rego

    ```
  </Accordion>

  <Accordion title="evaluate and show the data passed to the policy">
    ```shell theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
    kosli evaluate input 
    	--input-file trail-data.json 
    	--policy policy.rego 
    	--show-input 
    	--output json

    ```
  </Accordion>

  <Accordion title="read input from stdin">
    ```shell theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
    cat trail-data.json | kosli evaluate input 
    	--policy policy.rego

    ```
  </Accordion>

  <Accordion title="evaluate with policy parameters (inline JSON)">
    ```shell theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
    kosli evaluate input 
    	--input-file trail-data.json 
    	--policy policy.rego 
    	--params '{"threshold": 3}'

    ```
  </Accordion>

  <Accordion title="evaluate with policy parameters from a file">
    ```shell theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
    kosli evaluate input 
    	--input-file trail-data.json 
    	--policy policy.rego 
    	--params @params.json

    ```
  </Accordion>

  <Accordion title="evaluate using a policy fetched from a remote URL">
    ```shell theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
    kosli evaluate input 
    	--input-file trail-data.json 
    	--policy https://policies.example.com/policy.rego

    ```
  </Accordion>

  <Accordion title="evaluate as a decision point (print verdict, never fail the step)">
    ```shell theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
    kosli evaluate input 
    	--input-file trail-data.json 
    	--policy policy.rego 
    	--no-assert
    ```
  </Accordion>
</AccordionGroup>
