---
title: COPY with more than two arguments not ending with a slash
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > Code Security > Infrastructure as Code (IaC)
  Security > IaC Security Rules > COPY with more than two arguments not ending
  with a slash
---

# COPY with more than two arguments not ending with a slash

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md). ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}

{% /callout %}

## Metadata{% #metadata %}

**Id:** `dockerfile-copy-with-more-than-two-arguments-not-ending-with-slash` 

**Platform:** Dockerfile

**Severity:** Low

**Category:** Build Process

#### Learn More{% #learn-more %}

- [Provider Reference](https://docs.docker.com/engine/reference/builder/#copy)

### Description{% #description %}

`COPY` commands that reference a storage path must end directory arguments with a trailing slash so the command targets the intended directory prefix rather than a single object. Omitting the slash can lead to ambiguous file selection and accidental inclusion or exclusion of files, causing data integrity problems or unintended data exposure.

This check inspects `COPY` commands with more than two arguments and verifies that the final argument (the source path) ends with a `/` character. Resources where the command has more than two elements and the last element does not end with `/` will be flagged. Ensure the source path is explicitly a directory by including the trailing slash. For example:

```
COPY INTO my_table FROM 's3://my-bucket/path/' CREDENTIALS=...;
```

## Compliant Code Examples{% #compliant-code-examples %}

```dockerfile
FROM node:carbon
COPY package.json yarn.lock my_app/
```

```dockerfile
FROM node:carbon1
COPY package.json yarn.lock
```

## Non-Compliant Code Examples{% #non-compliant-code-examples %}

```dockerfile
FROM node:carbon2
COPY package.json yarn.lock my_app
```
