# Dependances

## Outils

### cdxgen

cdxgen permet de créer des BOM (Bills Of Materials) CycloneDX à partir du code source d'un projet.

Exemple d'utilisation:

`$ cdxgen -t java -o bom.json`

Ressource: <https://github.com/CycloneDX/cdxgen>

### Dependency-track

Dependency-track permet de monitorer les dependances d'un projet et leurs CVE associées.

Ressource: <https://github.com/DependencyTrack/dependency-track>

### Méthodologie

{% hint style="warning" %}
Note: Cette méthodologie nécessite d'avoir un accès au code source de l'application.
{% endhint %}

### 1. Génération d'un SBOM au format CycloneDX

Dans un premier temps, on génére un SBOM (Software Bill Of Materials) au format CycloneDX avec cdxgen.

Commande:

```
$ cdxgen -t java -o bom.json

ou avec docker,

$ docker run --rm \                                     
  -e CDXGEN_DEBUG_MODE=debug \
  -v /tmp:/tmp \                 
  -v "$(pwd):/app:rw" \
  -t ghcr.io/cyclonedx/cdxgen:master \
  -r /app \
  -o /app/bom.json
```

### 2. Lancement d'un serveur dependence-track

Téléchargement du docker compose:

`$ curl -LO https://dependencytrack.org/docker-compose.yml`

puis,

`$ docker-compose up -d`

Accéder au front-end à l'url **<http://0.0.0.0:8080>.**

{% hint style="info" %}
**Note**: les identifiants par défaut sont admin:admin
{% endhint %}

### 3. Création d'un projet et analyse de vulnérabilités

De là, il existe deux solutions qui sont soit de passer par le front-end directement, soit de passer par l'API REST de dependency-track.

#### Solution Front-end

Aller dans **Project** > **Create Project,**

Créer un projet, puis uploader le fichier bom.json dans le nouveau projet (onglet **Components** > bouton **Upload BOM**)

#### Solution Back-end

Générer une API Key via le front-end: [ http://0.0.0.0:8080/admin/accessManagement/teams](< http://localhost:8080/admin/accessManagement/teams>)

Upload le fichier bom.json via l'endpoint API REST:

```bash
curl --location 'http://localhost:8081/api/v1/bom' \
--header 'X-Api-Key: <API_KEY>' \
--form 'project="<PROJECT_ID>"' \
--form 'bom=@"/path/to/SBOM/file"'
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://blog.s1rn3tz.ovh/pentest-mobile/android/dependances.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
