{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://json.schemastore.org/sigrid-scope-file.schema.json",
  "additionalProperties": true,

  "definitions": {
    "organization": {
      "type": "string",
      "pattern": "^[a-z0-9]{2,}$"
    },
    "system": {
      "type": "string",
      "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
    },
    "model": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "20[0-9]{2}"
        },
        {
          "type": "integer",
          "minimum": 2000,
          "exclusiveMaximum": 2100
        }
      ]
    },
    "language_name": {
      "type": "string",
      "minLength": 1
    },
    "yyyymmdd": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "20\\d{2}-?\\d{2}-?\\d{2}"
        },
        {
          "type": "integer",
          "minimum": 20000000,
          "exclusiveMaximum": 21000000
        }
      ]
    },
    "interval": {
      "type": "string",
      "enum": ["week", "month"]
    },
    "branches": {
      "type": "string",
      "pattern": "^[0-9a-zA-Z]+(,[0-9a-zA-Z]+)*$"
    },
    "file_pattern_list": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "component": {
      "anyOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "properties": {
            "include": {
              "$ref": "#/definitions/file_pattern_list"
            },
            "exclude": {
              "$ref": "#/definitions/file_pattern_list"
            },
            "override": {
              "type": "boolean"
            }
          },
          "additionalProperties": false
        }
      ]
    },
    "component_list": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "include": {
            "$ref": "#/definitions/file_pattern_list"
          },
          "exclude": {
            "$ref": "#/definitions/file_pattern_list"
          }
        },
        "additionalProperties": false
      }
    },
    "language": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "name": {
              "$ref": "#/definitions/language_name"
            },
            "production": {
              "$ref": "#/definitions/component"
            },
            "test": {
              "$ref": "#/definitions/component"
            },
            "generated": {
              "$ref": "#/definitions/component"
            },
            "supplementary": {
              "$ref": "#/definitions/component"
            }
          },
          "additionalProperties": false
        },
        {
          "$ref": "#/definitions/language_name"
        }
      ]
    },
    "language_list": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/language"
      },
      "minItems": 1
    },
    "analyzer_list": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "pattern_list": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "system_element": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string"
        }
      },
      "required": ["name"],
      "additionalProperties": true
    },
    "system_element_list": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/system_element"
      }
    },
    "dependency": {
      "type": "object",
      "properties": {
        "source": {
          "type": "string"
        },
        "target": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "count": {
          "type": "integer"
        },
        "bidirectional": {
          "type": "boolean"
        }
      },
      "required": ["source", "target"],
      "additionalProperties": false
    },
    "dependency_list": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/dependency"
      }
    },
    "architecture_group": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "annotation": {
          "type": "string"
        },
        "include": {
          "$ref": "#/definitions/file_pattern_list"
        },
        "exclude": {
          "$ref": "#/definitions/file_pattern_list"
        }
      },
      "required": ["name", "include"],
      "additionalProperties": false
    },
    "architecture_group_list": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/architecture_group"
      }
    },
    "architecture_component_role": {
      "type": "object",
      "properties": {
        "role": {
          "type": "string"
        },
        "include": {
          "$ref": "#/definitions/file_pattern_list"
        },
        "exclude": {
          "$ref": "#/definitions/file_pattern_list"
        }
      },
      "required": ["role", "include"],
      "additionalProperties": false
    },
    "architecture_component_role_list": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/architecture_component_role"
      }
    },
    "architecture_patterns": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/architecture_pattern"
      }
    },
    "architecture_pattern": {
      "type": "object",
      "properties": {
        "description": {
          "type": "string"
        }
      },
      "required": ["description"],
      "additionalProperties": true
    },
    "dependency_checker_source": {
      "type": "string",
      "enum": ["all", "sbom"]
    }
  },

  "description": "Analysis scope configuration file used by Sigrid (sigrid-says.com)",

  "properties": {
    "default_excludes": {
      "type": "boolean",
      "description": "When true, excludes files and directories from the analysis scope based on common conventions."
    },
    "exclude": {
      "$ref": "#/definitions/file_pattern_list",
      "description": "List of file and directory patterns to manually exclude from the analysis."
    },
    "component_depth": {
      "type": "integer",
      "description": "Directory depth that will be used to define components."
    },
    "component_base_dirs": {
      "$ref": "#/definitions/file_pattern_list"
    },
    "components": {
      "$ref": "#/definitions/component_list"
    },
    "experimental": {
      "type": "boolean",
      "description": "Enable experimental analysis features."
    },
    "languages": {
      "$ref": "#/definitions/language_list",
      "description": "A list of technologies that should be included as part of the analysis."
    },
    "model": {
      "$ref": "#/definitions/model",
      "description": "SIG Maintainability Model that should be used for the analysis, defaults to latest."
    },

    "dependencychecker": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean",
          "description": "When this *or* the 'blocklist' option is provided, OSH analysis is performed for every upload."
        },
        "blocklist": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "List of patterns for library names that should not be sent to external services."
        },
        "blacklist": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Deprecated, use 'blocklist' instead."
        },
        "transitive": {
          "type": "boolean",
          "description": "When true, transitive dependencies are also checked and included in the results."
        },
        "exclude": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "properties": {
                  "path": {
                    "type": "string",
                    "description": "Excludes all dependencies in paths matching the specified regular expression."
                  }
                },
                "required": ["path"]
              },
              {
                "type": "object",
                "properties": {
                  "vulnerability": {
                    "type": "string",
                    "description": "Excludes all vulnerabilities matching the specified identifier (e.g. 'CVE-123')."
                  }
                },
                "required": ["vulnerability"]
              },
              {
                "type": "object",
                "properties": {
                  "license": {
                    "type": "string",
                    "description": "Excludes license risks identified in dependencies with the specified name."
                  }
                },
                "required": ["license"]
              },
              {
                "type": "object",
                "properties": {
                  "activity": {
                    "type": "string",
                    "description": "Excludes activity risks identified in dependencies with the specified name."
                  }
                },
                "required": ["activity"]
              }
            ]
          },
          "description": "List of paths and/or dependencies that should be ignored for Open Source Health."
        },
        "model": {
          "$ref": "#/definitions/model",
          "description": "SIG Open Source Health model version that should be used for the analysis, defaults to latest."
        },
        "override_enabled_technologies": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "List of additional technologies to analyze, which are not enabled by default."
        },
        "override_disabled_technologies": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "List of technologies for which the analysis should be disabled."
        },
        "source": {
          "$ref": "#/definitions/dependency_checker_source"
        }
      },
      "additionalProperties": false,
      "required": []
    },

    "architecture": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean",
          "description": "When true, architecture analysis will be triggered for each incoming upload."
        },
        "model": {
          "$ref": "#/definitions/model",
          "description": "SIG Architecture Quality Model that should be used for the analysis, defaults to latest."
        },
        "exclude": {
          "$ref": "#/definitions/file_pattern_list",
          "description": "List of exclude patterns that applies only to Architecture Quality, not globally."
        },
        "custom_components": {
          "type": "boolean",
          "description": "Deprecated. This option is obsolete."
        },
        "file_annotation_components": {
          "type": "boolean",
          "description": "Automatic componentization based on @sigrid:component annotations in source files."
        },
        "flatten_directories": {
          "$ref": "#/definitions/file_pattern_list",
          "description": "List of directory names that should be flattened and not considered as components during the analysis."
        },
        "add_system_elements": {
          "$ref": "#/definitions/system_element_list",
          "description": "List of system elements that are manually defined and added to the architecture graph."
        },
        "remove_system_elements": {
          "$ref": "#/definitions/system_element_list",
          "description": "List of system elements to manually remove from the architecture graph."
        },
        "add_dependencies": {
          "$ref": "#/definitions/dependency_list",
          "description": "List of manually added dependencies on top of the ones detected automatically by the analysis."
        },
        "remove_dependencies": {
          "$ref": "#/definitions/dependency_list",
          "description": "List of dependencies that manually overrides the analysis and removes them from the results."
        },
        "undesirable_dependencies": {
          "$ref": "#/definitions/dependency_list",
          "description": "List of dependencies considered undesirable, and should therefore be highlighted in the visualization."
        },
        "rename": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Map of system elements for which to manually override the name."
        },
        "merge_data_stores": {
          "type": "boolean",
          "description": "Default is false. When true, skips automated data store detection and assumes one monolithic data store."
        },
        "grouping": {
          "$ref": "#/definitions/architecture_group_list",
          "description": "Annotate all top-level components matching the pattern, in order to divide them into logical groups."
        },
        "component_roles": {
          "$ref": "#/definitions/architecture_component_role_list",
          "description": "Attaches role labels to all matching components, describing their role in the architecture."
        },
        "history_enabled": {
          "type": "boolean",
          "description": "Deprecated. This option is obsolete."
        },
        "history": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "string"
            }
          ],
          "description": "Deprecated. This option is obsolete."
        },
        "history_period_months": {
          "type": "integer",
          "description": "Period to use for repository history analysis, default is last 12 months."
        },
        "history_start": {
          "$ref": "#/definitions/yyyymmdd",
          "description": "Repository history start date in the format 'yyyy-mm-dd', default is last year."
        },
        "history_end": {
          "$ref": "#/definitions/yyyymmdd",
          "description": "Repository history end date in the format 'yyyy-mm-dd', default is current date."
        },
        "history_interval": {
          "$ref": "#/definitions/interval",
          "description": "Either 'week' (default) or ‘month’."
        },
        "history_filter_outliers": {
          "type": "boolean",
          "description": "Filters commits with an abnormally large amount of churn from the history analysis."
        },
        "branch": {
          "$ref": "#/definitions/branches",
          "description": "Deprecated. This option is obsolete."
        },
        "duplication": {
          "type": "boolean",
          "description": "Set to false to disable duplication detection, improves performance for huge systems."
        },
        "co_evolution": {
          "type": "boolean",
          "description": "Set to false to disable co-evolution detection, improves performance for huge systems."
        },
        "disabled_metrics": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "List of metrics that should be removed from the analysis and set to N/A."
        },
        "custom_patterns": {
          "$ref": "#/definitions/architecture_patterns",
          "description": "Adds additional custom patterns to the architecture knowledge base used for the analysis."
        }
      },
      "additionalProperties": false,
      "required": []
    },

    "thirdpartyfindings": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean",
          "description": "When true, third party findings analysis will be triggered for each incoming upload."
        },
        "disabled_analyzers": {
          "$ref": "#/definitions/analyzer_list",
          "description": "List of third-party analyzers that should not be ran."
        },
        "disabled_rules": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "List of rule IDs that should not be reported by Sigrid."
        },
        "enabled_analyzers": {
          "$ref": "#/definitions/analyzer_list",
          "description": "List of third-party analyzer names that should be ran even though they are disabled by default."
        },
        "enabled_rules": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "List of rule IDs that should be reported by Sigrid, even though they are disabled by default."
        },
        "include": {
          "$ref": "#/definitions/file_pattern_list",
          "description": "List of file/directory patterns that should be included in the third party findings analysis beyond the maintainability scope and production configuration files."
        },
        "exclude": {
          "$ref": "#/definitions/file_pattern_list",
          "description": "List of file/directory patterns that should be excluded from the third party findings analysis."
        }
      },
      "additionalProperties": false,
      "required": []
    },
    "checkmarx": false
  },
  "required": ["languages"],
  "title": "Sigrid scope configuration file",
  "type": "object"
}
