How To: Set a Baseline (API)

This quick tutorial shows how to set/update a baseline for a Fugue environment using the API:

You can set the baseline to the most recent scan or an earlier scan.

Note

You can also set or update a baseline using these other methods:

What’s a Baseline?

A baseline is a “snapshot” of resource configuration at a point in time. When you set a baseline, Fugue lets you know of any changes to that configuration, known as drift. Drift detection is automatically enabled when the baseline is set.

Whether you’re creating your first baseline or updating it, it’s called setting a baseline.

To set a baseline for an environment via the API, you’ll need two pieces of information:

  1. The environment ID

  2. The scan ID you’ll use as the baseline

Tip

Whether you’re setting the baseline to the most recent scan or an earlier one, just grab the ID of the desired scan.

We’ll show you how to do this via curl and Postman.

Setting a baseline with curl

Using curl:

1. Get the environment ID from a list of all environments:

curl -X GET \
"https://api.riskmanager.fugue.co/v0/environments" \
  -u $CLIENT_ID:$CLIENT_SECRET

In the response, look for the id field in each item to locate the environment ID you need:

{
 "count": 1,
 "is_truncated": false,
 "items": [
   {
     "baseline_id": null,
     "compliance_families": [
       "CIS-AWS_v1.2.0",
       "PCI-DSS_v3.2.1"
     ],
     "drift": false,
     "id": "ffc3aac1-9338-4965-ae30-3a8611111111",
     ...
   }
 ]
}

2. Get the scan ID from a list of scans for that environment, replacing YOUR_ENVIRONMENT_ID_HERE with the ID:

curl -X GET "https://api.riskmanager.fugue.co/v0/scans?environment_id=YOUR_ENVIRONMENT_ID_HERE" \
  -u $CLIENT_ID:$CLIENT_SECRET

In the response, look for the id field in each item to locate the scan ID you need:

{
  "count": 16,
  "is_truncated": false,
    "items": [
    {
      "created_at": 1553747169,
      "environment_id": "ffc3aac1-9338-4965-ae30-3a8611111111",
      "finished_at": 1553747373,
      "id": "8576a1b3-2f72-4e1d-902a-c81f22222222",
      "message": null,
      "remediation_error": false,
      "status": "SUCCESS",
      "updated_at": 1553747373
    }
  ]
}

3. Send a PATCH request and body to update the baseline using the selected scan ID, and save the body in a file named body.json.

Request:

curl -X PATCH \
"https://api.riskmanager.fugue.co/v0/environments/YOUR_ENVIRONMENT_ID_HERE" \
  -u $CLIENT_ID:$CLIENT_SECRET \
  -H "Content-Type: application/json" \
  -d @body.json

Body:

{
  "baseline_id": "YOUR_SCAN_ID_HERE"
}

You’ll see a response listing details of your environment including the updated baseline ID.

That’s it – you’re done! The next scan uses the updated baseline to detect drift or enforce resources.

Setting a baseline with Postman

Using Postman:

Step 1: Get environment ID

1. Get the environment ID from a list of all environments by selecting GET Lists details for all environments from the collection in the sidebar.

2. Click “Send.”

3. In the response, look for the id field in each item to locate the environment ID you need.

4. Copy the environment ID.

_images/postman-get-env-id.gif

Step 2: Get scan ID

1. Get the scan ID from a list of scans for that environment by selecting GET Lists scans for an environment from the sidebar.

2. Paste the environment ID into the environment_id query parameter field.

3. Click “Send.”

4. In the response, look for the id field in each item to locate the scan ID you need.

5. Copy the scan ID.

_images/postman-get-scan-id.gif

Step 3: Send update request and body

1. Send a request and body to update the baseline by selecting PATCH Updates an environment from the sidebar.

2. Paste the environment ID from step 3 into the environment_id path variable field.

3. Select the Body tab.

4. Delete all of the fields except for baseline_id, then paste the scan ID from step 7 as the value.

5. Click “Send.”

_images/postman-set-baseline.gif

You’ll see a response listing details of your environment including the updated baseline ID.

That’s it – you’re done! The next scan uses the updated baseline to detect drift or enforce resources.

What’s Next?

To learn more about the API, see the API User Guide and the API Reference.

Now that you’ve set a baseline, you can learn more about drift detection and baseline enforcement.

If you change your mind and want to disable drift detection, here’s how to do it.