# shishoctl CLI

The `shishoctl` CLI is a tool for operating Shisho Cloud. With this tool, you can deploy and manage policies on Shisho Cloud, providing an experience similar to using the `docker` or `kubectl` commands.

## Installation

The following commands install `shishoctl` for each supported environment:

<Tabs>
<TabItem value="linux-amd64" label="Linux (amd64)" default>

You can install `shishoctl` to `/usr/local/bin` with the following command:

```sh
SHISHOCTL_URL="https://shisho.dev/releases/shishoctl-0.15.0-x86_64-unknown-linux-gnu"
sudo curl -L $SHISHOCTL_URL -o /usr/local/bin/shishoctl
sudo chmod +x /usr/local/bin/shishoctl
```

</TabItem>

<TabItem value="linux-arm64" label="Linux (arm64)">

You can install `shishoctl` to `/usr/local/bin` with the following command:

```sh
SHISHOCTL_URL="https://shisho.dev/releases/shishoctl-0.15.0-aarch64-unknown-linux-gnu"
sudo curl -L $SHISHOCTL_URL -o /usr/local/bin/shishoctl
sudo chmod +x /usr/local/bin/shishoctl
```

</TabItem>

<TabItem value="apple-amd64" label="macOS (Intel CPU)">

You can install `shishoctl` to `/usr/local/bin` with the following command:

```sh
SHISHOCTL_URL="https://shisho.dev/releases/shishoctl-0.15.0-x86_64-apple-darwin"
sudo curl -L $SHISHOCTL_URL -o /usr/local/bin/shishoctl
sudo chmod +x /usr/local/bin/shishoctl
```

</TabItem>

<TabItem value="apple-arm64" label="macOS (Apple Silicon)">

You can install `shishoctl` to `/usr/local/bin` with the following command:

```sh
SHISHOCTL_URL="https://shisho.dev/releases/shishoctl-0.15.0-aarch64-apple-darwin"
sudo curl -L $SHISHOCTL_URL -o /usr/local/bin/shishoctl
sudo chmod +x /usr/local/bin/shishoctl
```

</TabItem>

<TabItem value="windows-amd64" label="Windows (amd64)">

Either use the Linux binary with an environment like WSL, or download from [https://shisho.dev/releases/shishoctl-0.15.0-x86_64-pc-windows-gnu.exe](https://shisho.dev/releases/shishoctl-0.15.0-x86_64-pc-windows-gnu.exe) and use it as `shishoctl.exe`.

</TabItem>

</Tabs>

## Sign in

By running the following command in an environment where the `shishoctl` command can be executed, you can sign in to Shisho Cloud from `shishoctl`:

```shell
shishoctl auth signin
```

:::note
The authentication information obtained from Shisho Cloud by the `shishoctl auth signin` command expires after a certain period. If you encounter an authentication error, please run the `shishoctl auth signin` command again.
:::

### Sign in as a Bot

When accessing Shisho Cloud in environments where a browser is not available, such as CI/CD or server environments, sign in using a [bot](/docs/c/bot/index.md) instead of a personal account. See [Bot / Authentication](/docs/c/bot/authentication.md) for the available methods - API key, GitHub Actions OIDC, GitLab CI OIDC, or a custom OIDC identity provider - and how to run `shishoctl auth signin:bot` with each of them.

## Example: Get a list of workflows

Once successfully signed in via the `shishoctl` CLI, you can perform a range of operations on Shisho Cloud using `shishoctl`. For example, the following command retrieves a list of workflows registered to the organization ID `org-a`:

```shell
shishoctl workflow list -o org-a
```

:::info
The organization ID refers to the ID registered when [creating an organization](/docs/g/getting-started/create-an-organization.md). If the organization ID is unclear, please follow the steps below to check it:

1. Open the Shisho Cloud dashboard in a web browser.
2. Check the organization ID (the `[oid]` part) in the URL displayed in your web browser, as shown below:

```
https://cloud.shisho.dev/[oid]/dashboard
```

:::

## Example: Chaining Multiple Commands

The `shishoctl` CLI outputs data in JSON or YAML format. This allows you to process the output of one command and use it as input for another, enabling complex chained operations.

For example, the following is a Python script that retrieves a list of findings in an organization, then gets the information of the resources targeted by each finding, and displays them together. Before running, please set the environment variables `SHISHOCTL_ORG_ID` (Organization ID) and `SHISHOCTL_PROJECT_ID` (Project ID).

```python
import subprocess
import yaml
import os

org_id = os.getenv("SHISHOCTL_ORG_ID")
project_id = os.getenv("SHISHOCTL_PROJECT_ID")

result = subprocess.run(
  ["shishoctl", "project", "finding", "list", "--org", org_id, "--project", project_id, "--format", "yaml"],
  capture_output=True,
  text=True,
)
parsed = yaml.safe_load(result.stdout)

summary = {"entries": []}
for i, finding in enumerate(parsed["entries"]):
  api_version = finding["id"]["apiVersion"]
  kind = finding["id"]["kind"]

  result = subprocess.run(
    ["shishoctl", "finding", "describe", "--org", org_id, api_version, kind],
    capture_output=True,
    text=True,
  )
  parsed = yaml.safe_load(result.stdout)

  summary["entries"].append({
    "id": {
      "apiVersion": api_version,
      "kind": kind,
    },
    "subjects": [],
  })

  for entry in parsed["decisions"]["entries"]:
    summary["entries"][i]["subjects"].append(entry['header']['subject'])

print(yaml.dump(summary))
```

## Checking How to Use Other Commands

For more information on how to use the `shishoctl` command, please see other pages on this website or run the following command:

```shell
shishoctl --help
```
