# Namespace Confusion API

Namespace Confusion is an attack where malicious packages are installed using weaknesses common in dependency management practices. These endpoints require the `EVALUATE_COMPONENT` permission in the IQ server.

See the [Namespace Confusion protection](https://help.sonatype.com/en/namespace-confusion-protection.html "Namespace Confusion Protection") documentation.

**Note**  
Namespace Confusion Protections applies to [proxy repositories supported by Repository Firewall](https://help.sonatype.com/en/repository-firewall.html#package-support-for-repository-firewall "Package Support for Repository Firewall") **except** for Docker and Hugging Face.  
Namespace Confusion Protection is **not** currently supported for Docker and Hugging Face.

## Add a Namespace to Protect

Use the following endpoint to add new namespaces to the Namespace Confusion protection.

```
POST /api/v2/firewall/namespace_confusion/maven
```

Example request

```
curl -X POST "http://localhost:8070/api/v2/firewall/namespace_confusion/maven" \
  --header 'Content-Type: application/json' \
  -u admin:admin123 \
  -d '["org.sonatype"]'
```

The passed in data element includes an array of namespaces to add. An asterisk character (*) may be used as a wild card.

### Repository Endpoints

When a namespace is added through the IQ API, IQ does not create or use a real Nexus Repository Manager repository. Instead, it always creates or reuses a logical Nexus Repository instance with the deployment or instance ID `namespace_confusion`.

Within this instance, IQ creates or reuses logical repositories named `nsc_{format}`, such as `nsc_maven` or `nsc_npm`. These repositories exist only within the `namespace_confusion` instance and are used internally by IQ to manage namespaces.

## Remove all Namespaces

Removes the contents of the entire namespace repository.

```
DELETE /api/v2/firewall/namespace_confusion/maven
```

```
curl -X DELETE "http://localhost:8070/api/v2/firewall/namespace_confusion/maven" \
  --header 'Content-Type: application/json' \
  -u admin:admin123'
```

## Search results

No results found.
