Rules and Ruleset Endpoints
  • 26 Oct 2021
  • 3 Minutes to read
  • Dark
    Light
  • PDF

Rules and Ruleset Endpoints

  • Dark
    Light
  • PDF

Article summary

These endpoints provide information about a team's rulesets and provide the ability to create new rulesets.

Create Ruleset - Creates a new ruleset.
Get Rules - Returns all Ion Channel rules and their IDs.
Get Ruleset - Returns information about a single specified ruleset.
Get Rulesets - Returns information about all rulesets that exist in a given team.
Update Ruleset for Existing Project - Changes the ruleset for one or more projects.


Create Ruleset

The v1/ruleset/createRuleset endpoint allows you to create a new ruleset.

Endpoint
v1/ruleset/createRuleset
Request Method
POST
ParameterDescription
team_idYour team ID.
rule_idsThe IDs for the rules to be applied to the ruleset. See Get Rules.
nameThe name of the ruleset.
description(optional) A description of the ruleset.

Request Example

curl -X POST \

-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer TOKEN" \
-d '{
   "team_id":"TEAM_ID",
   "rule_ids":["81959ec3-2b6d-4bd4-b94b-6ce2533524bb","f746023f-16cc-46db-9422-1e4e3364ab97"],
   "name":"Ruleset Name",
   "description":""
}' \
"https://api.ionchannel.io/v1/ruleset/createRuleset"

Response Example

{
  "data": {
    "id": "abcd1234-ab12-ab12-ab12-abcde123456",
    "team_id": "abcd1234-ab12-ab12-ab12-abcde123456",
    "name": "Ruleset Name",
    "description": "",
    "rule_ids": [
      "81959ec3-2b6d-4bd4-b94b-6ce2533524bb",
      "f746023f-16cc-46db-9422-1e4e3364ab97"
    ],
    "created_at": "2021-05-12T22:58:17.250Z",
    "updated_at": "2021-05-12T22:58:17.250Z",
    "deleted_at": null,
    "deleted_by": null,
    "rules": [
      {
        "id": "81959ec3-2b6d-4bd4-b94b-6ce2533524bb",
        "scan_type": "external_vulnerability",
        "name": "No High and Up external vulnerabilities",
        "description": "When this rule is enabled, an analysis will fail if external scan data is not present or the data reports finding any high or critical vulnerabilities. External vulnerabilities scan is performed by 3rd party scanning tools and is configured via the Ionize CLI tool.",
        "category": "Vulnerabilities",
        "created_at": "2018-01-30T18:16:09.762Z",
        "updated_at": "2021-05-08T12:41:31.752Z",
        "deprecated": null
      },
      {
        "id": "f746023f-16cc-46db-9422-1e4e3364ab97",
        "scan_type": "virus",
        "name": "Has no viruses",
        "description": "When this rule is enabled, an analysis will fail if any virus is detected.",
        "category": "Virus",
        "created_at": "2017-07-19T19:15:41.770Z",
        "updated_at": "2021-05-08T12:41:31.824Z",
        "deprecated": null
      }
    ]
  },
  "meta": {
    "copyright": "Copyright Selection Pressure LLC www.selectpress.net",
    "authors": [
      "Ion channel"
    ],
    "version": "v1"
  },
  "links": {
    "self": "https://api.ionchannel.io/v1/ruleset/createRuleset",
    "created": "https://api.ionchannel.io/v1/ruleset/createRuleset?id=823d7ea6-cc50-4aca-b4f5-a8112456080f"
  },
  "timestamps": {
    "created": "2021-05-12T22:58:17Z",
    "updated": "2021-05-12T22:58:17Z"
  }
}

Get Rules

The v1/ruleset/getRules endpoint returns all of the available rules that can be applied to a ruleset. This can be useful to obtain a rule ID to be used when creating a new ruleset.

Endpoint
v1/ruleset/getRules
Request Method
GET

Request Example

curl -H "Authorization: Bearer TOKEN" \
https://api.ionchannel.io/v1/ruleset/getRules

Response Example


Get Ruleset

The v1/ruleset/getRuleset endpoint returns information on a single ruleset. This includes the ruleset name, ID, the rules applied to the ruleset, and whether the ruleset is active and assigned to any projects.

Endpoint
v1/ruleset/getRuleset
Request Method
GET
ParameterDescription
idThe ruleset ID.
team_id
Your team ID.

Request Example:

curl -H "Authorization: Bearer TOKEN" \
https://api.ionchannel.io/v1/ruleset/getRuleset?id=RULESET_ID&team_id=TEAM_ID

Response Example:

{
  "data": [
    {
      "id": "abcd1234-ab12-ab12-ab12-abcde123456",
      "team_id": "abcd1234-ab12-ab12-ab12-abcde123456",
      "name": "No Viruses/Vulnerabilities",
      "description": "Project must not have any viruses or high/critical severity vulnerabilities.",
      "rule_ids": [
        "00be1862-959c-45d8-8fb5-2b748fe854d6",
        "f746023f-16cc-46db-9422-1e4e3364ab97"
      ],
      "created_at": "2020-01-31T23:59:04.351734Z",
      "updated_at": "2020-01-31T23:59:04.351734Z",
      "rules": [
        {
          "id": "00be1862-959c-45d8-8fb5-2b748fe854d6",
          "scan_type": "vulnerabilities",
          "name": "High And Up Vulnerabilities < 1",
          "description": "When this rule is enabled, an analysis will fail if the number of high or critical severity vulnerabilities discovered exceeds the maximum allowed value.",
          "category": "Vulnerabilities",
          "created_at": "2016-09-21T19:31:45.918019Z",
          "updated_at": "2021-05-08T12:41:31.764147Z",
          "deprecated": false
        },
        {
          "id": "f746023f-16cc-46db-9422-1e4e3364ab97",
          "scan_type": "virus",
          "name": "Has no viruses",
          "description": "When this rule is enabled, an analysis will fail if any virus is detected.",
          "category": "Virus",
          "created_at": "2017-07-19T19:15:41.770197Z",
          "updated_at": "2021-05-08T12:41:31.824414Z",
          "deprecated": false
        }
      ],
      "has_deprecated_rules": false,
      "has_projects_assigned": true
    }
  ],
  "meta": {
    "total_count": 0,
    "offset": 0
  }
}

Get Rulesets

The v1/ruleset/getRulesets endpoint returns the same information as the getRuleset endpoint, but it includes all of the rulesets that exist for the specified team.

Endpoint
v1/ruleset/getRulesets
Request Method
GET
ParameterDescription
team_idYour team ID.

Request Example:

curl -H "Authorization: Bearer TOKEN" \
https://api.ionchannel.io/v1/ruleset/getRulesets?team_id=TEAM_ID

Response Example:

See Get Ruleset.


Update Ruleset

The v1/project/updateRulesetForProjects endpoint allows you to change the ruleset for one or more existing projects.

Endpoint
v1/project/updateRulesetForProjects
Request Method
PUT
ParameterDescription
project_idsThe project IDs to be updated.
ruleset_idThe ruleset ID to be applied to the projects.

Request Example

curl -X PUT \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer TOKEN" \
-d '{
   "ruleset_id":"abcd1234-ab12-ab12-ab12-abcde123456",
   "project_ids":["bcde1234-ab12-ab12-ab12-abcde234567","cdef1234-ab12-ab12-ab12-abcde345678"]
}' \
"https://api.ionchannel.io/v1/project/updateRulesetForProjects"

Response Example

{
  "data": {
    "succeeded": [
      "bcde1234-ab12-ab12-ab12-abcde234567",
      "cdef1234-ab12-ab12-ab12-abcde345678"
    ],
    "failed": []
  },
  "meta": {
    "total_count": 2,
    "offset": 0,
    "last_update": "2021-10-26T17:14:15.699504033Z"
  }
}

Was this article helpful?

What's Next