> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flexagon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# analyzeLocalImage (Anchore)

> This operation will scan a locally built docker image and upload the results to an Anchore Engine installation. If you are just looking to scan and no

This operation will scan a locally built docker image and upload the results to an Anchore Engine installation. If you are just looking to scan and not upload the results, see [scanLocalImage](https://docs.flexagon.com/flexdeploy-9-0-documentation/flexdeploy-plugin-guides/flexdeploy-anchore-plugin-guide/scanlocalimage-anchore.md). By default, the analyze operations do not return the analyzed results but that behavior can be changed by selecting **Wait For Results**.

# Inputs

<table><colgroup><col /><col /><col /><col /></colgroup><tbody><tr><th>**Input Name**</th><th>**Input Code**</th><th>**Required**</th><th>**Description**</th></tr><tr><td>Anchore User</td><td>`FDANCR_INP_USER`</td><td>Yes</td><td>The Anchore User used when uploading the results.</td></tr><tr><td>Anchore Password</td><td>`FDANCR_INP_PASSWORD`</td><td>Yes</td><td>The Anchore Password used when uploading the results.</td></tr><tr><td>Anchore Url</td><td>`FDANCR_INP_URL`</td><td>Yes</td><td>The API url for the Anchore Engine install. Typically, **[http://yourhost:8228/v1](http://yourhost:8228/v1)**</td></tr><tr><td>Image Name</td><td>`FDANCR_INP_IMAGE_NAME`</td><td>Yes</td><td>The full image tag to analyze. For example, **ubuntu:16.06** or **myuser/myimage:latest**</td></tr><tr><td>Wait For Results</td><td>`FDANCR_INP_WAIT_FOR_RESULTS`</td><td>Yes</td><td>Should the plugin wait for the results or simply start the upload and complete. If you want to use the Groovy Fail Condition or Plugin Outputs this needs to be true.</td></tr><tr><td>Groovy Fail Condition</td><td>`FDANCR_INP_SCAN_FAIL_CONDITION`</td><td>No</td><td>Optional groovy script to determine if the scan should fail the workflow. Available variables include all FlexDeploy environment variables and the following scan result variables:<ul><li>STATUS</li><li>FINAL\_ACTION</li><li>STOP\_COUNT</li><li>WARN\_COUNT</li><li>ALL\_COUNTS</li></ul>See more information [here ](https://docs.flexagon.com/flexdeploy-9-0-documentation/flexdeploy-plugin-guides/flexdeploy-anchore-plugin-guide.md)for configuring the Groovy Fail Condition.</td></tr><tr><td>Scan Timeout</td><td>`FDANCR_INP_TIMEOUT`</td><td>No</td><td>By default, the scan will timeout if it exceeds 900 seconds (15min). This is likely more than enough time, but the timeout can be increased here if needed.</td></tr></tbody></table>

# Outputs

Each operation in this plugin supplies the option to configure a Groovy script to determine if the scan results are inacceptable and should fail the operation. Below is a list of variables available to the Groovy script.

> [!NOTE]
>
> Each of these variables is also available as a plugin output

<table><colgroup><col /><col /><col /><col /></colgroup><tbody><tr><th>**Groovy Variable**</th><th>**Plugin Output**</th><th>**Description**</th><th>**Example**</th></tr><tr><td>STATUS</td><td>`FDANCR_OUT_STATUS`</td><td>Overall status of the scan/analysis. This is ultimately determined by the policy bundle that is used. Possible values are **pass** or **fail**.</td><td>fail</td></tr><tr><td>FINAL\_ACTION</td><td>`FDANCR_OUT_FINAL_ACTION`</td><td>Similar to the status, this provides the recommended action for the image.</td><td>stop</td></tr><tr><td>STOP\_COUNT</td><td>`FDANCR_OUT_STOP_COUNT`</td><td>An integer count of the number of STOP rules detected for the image</td><td>2</td></tr><tr><td>WARN\_COUNT</td><td>`FDANCR_OUT_WARN_COUNT`</td><td>An integer count of the number of WARN rules detected for the image</td><td>10</td></tr><tr><td>ALL\_COUNTS</td><td>`FDANCR_OUT_ALL_COUNT_LIST`</td><td>A full list of all counts returned</td><td>\[STOP:2, WARN:10, GO:37]</td></tr><tr><td /><td /><td>All other FlexDeploy Variables are also available in the Groovy Script Condition</td><td /></tr></tbody></table>

### Example Groovy Script Conditions

* The most common use case lets the policy bundle unequivocally determine failure.

  ```
  STATUS == "fail"
  ```

* No warn or stop checks found

  ```
  (STOP_COUNT + WARN_COUNT) != 0
  ```

* A script that is more lenient on non-master stream builds (could be only master stream is pushed to the registry and other streams are for local testing).

  ```
  //master is not allowed any stop checks whereas every other stream can have 5 or less
  FDBLD_STREAM_NAME == "master" ? STOP_COUNT > 0 : STOP_COUNT > 5
  ```

> [!NOTE]
>
> ### Outputs
>
> These outputs will only be returned if **Wait For Results** is true

# Artifacts

This operation delegates the consume/produce artifacts decision to the workflow developer.

# Endpoint Selection

This operation delegates endpoint selection to the workflow developer. The workflow editor will default the selection to "All", which selects all available endpoints associated to the target. Selecting a specific resource will result in selection of endpoints associated to the target which have that resource defined. 

# Endpoint Execution

This operation delegates endpoint execution to the workflow developer. The workflow editor will default to "Any", which will execute on any one of the selected endpoints, which will be randomly picked from selected endpoints or a specific endpoint where previous step may have executed. Changing this value to "All" to will result in execution on all selected endpoints. 

# Special Considerations

### Anchore Engine Image Tags

This plugin uses [Anchore CI Tools](https://github.com/anchore/ci-tools) to perform local scanning/analyzing. Anchore Engine requires images to be pushed to a registry prior to analyzing. The Anchore CI Tools get around this by starting a temporary local Anchore container with a '**localbuild**' registry. This allows you to scan and analyze images directly after building on your local docker engine.

What this means is that any images analyzed via this operation will be tagged in Anchore Engine with a **localbuild** registry, like so: 

```
#local image
company/ourapp:latest

#image tag in Anchore Engine
localbuild/company/ourapp:latest
```
