# Command Line Interface

This section describes the various commands available.

All commands below are run from the Vulnerability-Lookup project directory using `poetry run`.

## Core

### Start all the services

```bash
$ poetry run start
```

### Stop all the services

```bash
$ poetry run stop
```

### Start/stop the backend (Valkey and Kvrocks)

```bash
$ poetry run run_backend --start
$ poetry run run_backend --stop
```

### Start/stop all enabled feeders

```bash
$ poetry run feeders_manager --start
$ poetry run feeders_manager --stop
```

### Start only the website

```bash
$ poetry run start_website
```

### Restart only the website

```bash
$ poetry run restart_website
```

### Dump a source in a JSON file

```bash
$ poetry run dump --feed nvd
```

### Run an individual feeder manually

```bash
$ poetry run nvd_importer
$ poetry run cvelist_importer
$ poetry run github_importer
```

See `pyproject.toml` under `[project.scripts]` for the full list of available feeder commands.

### Update the documentation

```bash
$ cd docs; poetry run make html
```

## Web service

This section describes the main commands related to the web service.
All Flask commands are prefixed with `poetry run flask --app website.app`.

### Database

Init the database:

```bash
$ poetry run flask --app website.app db_init
```

Backup the PostgreSQL database (also runs automatically during `poetry run update`):

```bash
$ poetry run flask --app website.app db_backup
```

Generate a database models diagram:

```bash
$ poetry run flask --app website.app db_diagram
```

### User management

Create a user:

```bash
$ poetry run flask --app website.app create_user --login <login> --email <email> --password <password>
```

Create an admin:

```bash
$ poetry run flask --app website.app create_admin --login <login> --email <email> --password <password>
```

List all users:

```bash
$ poetry run flask --app website.app user_list
```

Delete a user:

```bash
$ poetry run flask --app website.app user_delete --login <login>
```

Retrieve a user's API key:

```bash
$ poetry run flask --app website.app user_get_api_key --login <login>
```

### Data management

Update MISP warning lists (the administrator will be prompted to run this during updates):

```bash
$ poetry run flask --app website.app update_warninglists
```

Update the local copy of the GCVE registry (can be scheduled via cron):

```bash
$ poetry run flask --app website.app update_gcve_registry
```

Import OSI-approved licenses:

```bash
$ poetry run flask --app website.app import_osi_approved_licenses
```

Import source code languages:

```bash
$ poetry run flask --app website.app import_languages
```

Clean sightings by source or pattern:

```bash
$ poetry run flask --app website.app clean_sightings
```

Backfill sightings from existing data:

```bash
$ poetry run flask --app website.app backfill_sightings
```

Creates sightings retroactively from all existing comments (*seen*), bundles (*seen*,
one per vulnerability), and KEV entries (*exploited*). Each sighting inherits the
`creation_timestamp` of its source object. The command is **idempotent**: running it
multiple times will not create duplicates, as it skips any entry whose source URL
already exists in the database.

### Background services

Launch the email notification service:

```bash
$ poetry run flask --app website.app notify_users
```

Launch the synchronization service (see {doc}`sync` for details):

```bash
$ poetry run flask --app website.app sync
```
