# Morph extractor

The Morph extractor gathers evidence about an application from inside your own network, so a Morph investigation can understand it and map it to Salesforce. It's a single Python file, [morph-extract.py](morph-extract.py), and it needs Python 3.8 or later.

It reads metadata, configuration and code, and never copies business records. Everything it collects goes into one bundle, `morph-evidence-<name>.zip`, with a `MANIFEST.json` that lists every item. Check the manifest, then upload the bundle to the investigation in Morph.

## Before you start
- Only run it on systems the client owns or has authorised Capgemini to analyse.
- Use a **read-only** database account.
- Passwords are asked for at the prompt (or read from `MORPH_DB_PASSWORD`) and are never saved.
- Secret-looking values in configuration (`password=`, `secret=`, `token=`, `api_key=` and similar) are replaced with `[removed by Morph extractor]`. The manifest shows how many were removed.

## Oracle databases
```
pip install oracledb
python3 morph-extract.py oracle --dsn dbhost:1521/ORCLPDB1 --user APP_READONLY --schemas APP,HR --source --profile --name acme-db
```
- **Always included:** tables, columns, comments, keys and constraints, indexes, views and their SQL, packages, procedures, triggers, sequences, scheduled jobs and dependencies. These come only from Oracle's `ALL_*` data dictionary views.
- **`--source`** also includes the PL/SQL source code.
- **`--profile`** also includes counts and summary statistics, but no records:
  - row counts
  - how full each column is
  - up to 30 values for small, code-like columns (statuses, types)

  Columns that look personal (names, emails, phones, addresses, dates of birth, notes) get counts only.

The connection uses python-oracledb's thin mode, so no Oracle client install is needed.

## Java applications
```
python3 morph-extract.py java --path /srv/acme-app --copy-source --name acme-app
```
- **Inventory:** the inventory lists every Java type, its annotations (JPA entities and columns, Spring controllers and request mappings, validation, security and scheduling) and its public methods.
- **Configuration and mapping files:** files such as `application.yml`, `persistence.xml`, Hibernate mappings, SQL, WSDL and BPMN are included, with secrets removed.
- **Packaged apps:** WAR, EAR and JAR files are listed (classes and libraries), their configuration files are kept, and the archive itself is included so the investigator can analyse it.
- **`--copy-source`** also includes the source files themselves, with secrets removed.

## Microsoft Dynamics 365
If Morph can reach the Dynamics org directly, an admin can connect it instead: on the Builds page, open **Source systems to investigate**. Otherwise, export an unmanaged solution from **Solutions > Export**, then run:
```
python3 morph-extract.py dynamics --solution AcmeCore_1_0_0_0.zip --name acme-dynamics
```

## Anything else
```
python3 morph-extract.py files --path /path/to/exports-or-docs --name acme-docs
```

## Then
Upload the bundle when the investigation asks for evidence, either on its card on the Builds page or in its chat.
