// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

syntax = "proto3";

package harp.bundle.v1;

option csharp_namespace = "Harp.Bundle.V1";
option go_package = "github.com/elastic/harp/api/gen/go/harp/bundle/v1;bundlev1";
option java_multiple_files = true;
option java_outer_classname = "RuleSetProto";
option java_package = "com.github.elastic.cloudsec.harp.bundle.v1";
option objc_class_prefix = "SBX";
option php_namespace = "Harp\\Bundle\\V1";

// RuleSet represents bundle linter ruleset definition.
message RuleSet {
  // Default to ""
  string api_version = 1;
  // Default to "RuleSet"
  string kind = 2;
  // RuleSet metadata
  RuleSetMeta meta = 3;
  // RuleSet specification
  RuleSetSpec spec = 4;
}

// PatchMeta handles patch metadata.
message RuleSetMeta {
  // REQUIRED. RuleSet name.
  string name = 1;
  // REQUIRED. RuleSet owner.
  string owner = 2;
  // REQUIRED. Short description for ruleset.
  string description = 3;
}

// RuleSetSpec repesents ruleset specification holder.
message RuleSetSpec {
  // Rule collection.
  repeated Rule rules = 1;
}

// Rule represents linter rule specification.
message Rule {
  // REQUIRED. Rule name.
  string name = 1;
  // OPTIONAL. Rule description.
  string description = 2;
  // REQUIRED. Rule path matcher filter.
  string path = 3;
  // OPTIONAL. CEL Constraint collection.
  repeated string constraints = 4;
  // OPTIONAL. Rego policy.
  string rego = 5;
  // OPTIONAL. Rego policy file.
  string rego_file = 6;
}
