mappings

package
v0.0.0-...-9697014 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2025 License: Apache-2.0 Imports: 2 Imported by: 6

Documentation

Index

Constants

View Source
const (

	//N.B. - the two IndicesVersion consts may very well be different from one another.  it's important to only change the one(s) that need migration.
	//if we tied both to the same version, then a simple change to profiles structure would require us to do a full migration of timeseries (which is time consuming)
	//the net result of separating them is that we can migrate them when one or both change by simply incrementing one or both.  cool, right!?
	//ComplianceCurrentTimeSeriesIndicesVersion allows us to know, for any version of compliance, what level we are at with our timeseries indices
	ComplianceCurrentTimeSeriesIndicesVersion = "7"
	//ComplianceCurrentProfilesIndicesVersion allows us to know, for any version of compliance, what level we are at with our profiles and profiles-mappings indices
	ComplianceCurrentProfilesIndicesVersion = "3"
	ComplianceCurrentRunInfoVersion         = "3"
	ComplianceCurrentControlInfoVersion     = "1"

	IndexNameProf              = compAndVersionProfiles + "-profiles"
	IndexNameComplianceRunInfo = compAndVersionRunInfo + "-run-info"

	IndexNameRep = compAndVersionTimeSeries + "-r"
	IndexNameSum = compAndVersionTimeSeries + "-s"

	IndexNameControl = compAndControlRunInfo + "-control"
)

Variables

AllMappings is the list of all mappings that we currently have and it is used by our `InitializeStore()` interface, if we add more mappings to this list, the function will automatically initialize them

View Source
var ComplianceControlRepData = Mapping{
	Index:      IndexNameControl,
	Timeseries: true,
	Mapping: `
{
  "index_patterns": [
    "` + IndexNameControl + `-20*"
  ],
  "settings": {
    "analysis": {
      "analyzer": {
        "autocomplete": {
          "filter": [
            "lowercase"
          ],
          "tokenizer": "autocomplete_tokenizer"
        },
        "autocomplete_version_numbers": {
          "filter": [
            "lowercase"
          ],
          "tokenizer": "autocomplete_version_number_tokenizer"
        }
      },
      "tokenizer": {
        "autocomplete_tokenizer": {
          "max_gram": 20,
          "min_gram": 2,
          "token_chars": [
            "letter",
            "digit"
          ],
          "type": "edge_ngram"
        },
        "autocomplete_version_number_tokenizer": {
          "max_gram": 20,
          "min_gram": 2,
          "token_chars": [
            "letter",
            "digit",
            "punctuation"
          ],
          "type": "edge_ngram"
        }
      },
      "normalizer": {
        "case_insensitive": {
          "type": "custom",
          "char_filter": [],
          "filter": [
            "lowercase",
            "asciifolding"
          ]
        }
      }
    },
    "index": {
      "refresh_interval": "1s"
    }
  },
  "mappings": {
    "properties": {
      "control_id": {
        "type": "keyword"
      },
      "title": {
        "type": "keyword",
        "fields": {
          "engram": {
            "type": "text",
            "analyzer": "autocomplete"
          },
          "lower": {
            "type": "keyword",
            "normalizer": "case_insensitive"
          }
        }
      },
      "waived_str": {
        "type": "keyword"
      },
      "waiver_data": {
        "properties": {
          "expiration_date": {
            "type": "keyword"
          },
          "justification": {
            "type": "keyword"
          },
          "message": {
            "type": "keyword"
          },
          "run": {
            "type": "boolean"
          },
          "skipped_due_to_waiver": {
            "type": "boolean"
          }
        }
      },
      "impact": {
        "type": "double"
      },
      "string_tags": {
        "type": "nested",
        "properties": {
          "key": {
            "type": "keyword",
            "fields": {
              "engram": {
                "type": "text",
                "analyzer": "autocomplete"
              },
              "lower": {
                "type": "keyword",
                "normalizer": "case_insensitive"
              }
            }
          },
          "values": {
            "type": "keyword",
            "fields": {
              "engram": {
                "type": "text",
                "analyzer": "autocomplete"
              },
              "lower": {
                "type": "keyword",
                "normalizer": "case_insensitive"
              }
            }
          }
        }
      },
      "status": {
        "type": "keyword"
      },
      "daily_latest": {
        "type": "boolean"
      },
      "day_latest": {
        "type": "boolean"
      },
      "end_time": {
        "type": "date"
      },
      "nodes": {
        "properties": {
          "node_uuid": {
            "type": "keyword"
          },
          "environment": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
         "job_uuid": {
            "type": "keyword"
          },
          "node_name": {
            "type": "keyword",
            "fields": {
              "engram": {
                "type": "text",
                "analyzer": "autocomplete"
              },
              "lower": {
                "type": "keyword",
                "normalizer": "case_insensitive"
              }
            }
          },
          "platform": {
            "properties": {
              "name": {
                "fields": {
                  "engram": {
                    "analyzer": "autocomplete",
                    "type": "text"
                  },
                  "lower": {
                    "normalizer": "case_insensitive",
                    "type": "keyword"
                  }
                },
                "type": "keyword"
              },
              "release": {
                "fields": {
                  "engram": {
                    "analyzer": "autocomplete",
                    "type": "text"
                  },
                  "lower": {
                    "normalizer": "case_insensitive",
                    "type": "keyword"
                  }
                },
                "type": "keyword"
              },
              "full": {
                "fields": {
                  "engram": {
                    "analyzer": "autocomplete_version_numbers",
                    "type": "text"
                  },
                  "lower": {
                    "normalizer": "case_insensitive",
                    "type": "keyword"
                  }
                },
                "type": "keyword"
              }
            }
          },
          "recipes": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "roles": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "policy_name": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "policy_group": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "organization_name": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "source_fqdn": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "chef_tags": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "end_time": {
            "type": "date"
          },
          "status": {
            "type": "keyword"
          },
          "daily_latest": {
            "type": "boolean"
          },
          "day_latest": {
            "type": "boolean"
          },
          "report_uuid": {
            "type": "keyword"
          }
        },
        "type": "nested"
      },
      "profile": {
        "properties": {
          "profile": {
            "type": "keyword"
          },
          "sha256": {
            "type": "keyword"
          },
          "name": {
            "type": "keyword"
          },
          "title": {
            "type": "keyword",
            "fields": {
              "engram": {
                "type": "text",
                "analyzer": "autocomplete"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            }
          }
        }
      },
      "report_uuid": {
        "type": "keyword"
      }
    }
  }
}`,
}

ComplianceControlRepData Compliance mapping used to create the `comp-<version>-control-<date>` index

View Source
var ComplianceProfiles = Mapping{
	Index:      IndexNameProf,
	Timeseries: false,
	Mapping: `
  {
    "index_patterns": ["` + IndexNameProf + `"],
    "settings": {
      "index": {
        "refresh_interval": "1s",
        "number_of_shards": "5"
      },
      "analysis": {
        "analyzer": {
          "autocomplete": {
            "tokenizer": "autocomplete_tokenizer",
            "filter": [
              "lowercase"
            ]
          }
        },
        "tokenizer": {
          "autocomplete_tokenizer": {
            "type": "edge_ngram",
            "min_gram": 2,
            "max_gram": 20,
            "token_chars": [
              "letter",
              "digit"
            ]
          }
        },
        "normalizer": {
          "case_insensitive": {
            "type": "custom",
            "char_filter": [],
            "filter": [
              "lowercase",
              "asciifolding"
            ]
          }
        }
      }
    },
    "mappings": {
      "properties": {
        "name": {
          "type": "keyword",
          "fields": {
            "lower": {
              "normalizer": "case_insensitive",
              "type": "keyword"
            }
          }
        },
        "title": {
          "type": "keyword",
          "fields": {
            "engram": {
              "type": "text",
              "analyzer": "autocomplete"
            },
            "lower": {
              "normalizer": "case_insensitive",
              "type": "keyword"
            }
          }
        },
        "maintainer": {
          "type": "keyword"
        },
        "copyright": {
          "type": "keyword"
        },
        "copyright_email": {
          "type": "keyword"
        },
        "license": {
          "type": "keyword"
        },
        "summary": {
          "type": "keyword"
        },
        "version": {
          "type": "keyword"
        },
        "supports": {
          "type": "object",
          "properties": {
            "os-family": {
              "type": "keyword"
            },
            "os-name": {
              "type": "keyword"
            },
            "platform": {
              "type": "keyword"
            },
            "platform-name": {
              "type": "keyword"
            },
            "platform-family": {
              "type": "keyword"
            },
            "release": {
              "type": "keyword"
            },
            "inspec": {
              "type": "keyword"
            }
          }
        },
        "controls": {
          "type": "nested",
          "properties": {
            "title": {
              "type": "keyword"
            },
            "desc": {
              "type": "keyword"
            },
            "description": {
              "properties": {
                "label": {
                  "type": "keyword"
                },
                "data": {
                  "type": "keyword"
                }
              }
            },
            "impact": {
              "type": "double"
            },
            "refs": {
              "type": "keyword"
            },
            "tags": {
              "type": "keyword"
            },
            "code": {
              "type": "keyword"
            },
            "source_location": {
              "type": "object",
              "properties": {
                "ref": {
                  "type": "keyword"
                },
                "line": {
                  "type": "integer"
                }
              }
            },
            "id": {
              "type": "keyword",
              "fields": {
                "engram": {
                  "type": "text",
                  "analyzer": "autocomplete"
                },
                "lower": {
                  "normalizer": "case_insensitive",
                  "type": "keyword"
                }
              }
            }
          }
        },
        "groups": {
          "type": "object",
          "properties": {
            "title": {
              "type": "keyword"
            },
            "controls": {
              "type": "keyword"
            },
            "id": {
              "type": "keyword"
            },
            "attributes": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "keyword"
                },
                "options": {
                  "type": "object",
                  "properties": {
                    "default": {
                      "type": "keyword"
                    },
                    "description": {
                      "type": "keyword"
                    }
                  }
                }
              }
            },
            "sha256": {
              "type": "keyword"
            }
          }
        }
      }
    }
  }
	`,
}

ComplianceProfiles mapping used to create the `compliance-profiles` index

View Source
var ComplianceRepDate = Mapping{
	Index:      IndexNameRep,
	Timeseries: true,
	Mapping: `
  {
    "index_patterns": ["` + IndexNameRep + `-20*"],
    "settings": {
      "analysis": {
        "analyzer": {
          "autocomplete": {
            "filter": [
              "lowercase"
            ],
            "tokenizer": "autocomplete_tokenizer"
          },
          "autocomplete_version_numbers": {
            "filter": [
              "lowercase"
            ],
            "tokenizer": "autocomplete_version_number_tokenizer"
          }
        },
        "tokenizer": {
          "autocomplete_tokenizer": {
            "max_gram": 20,
            "min_gram": 2,
            "token_chars": [
              "letter",
              "digit"
            ],
            "type": "edge_ngram"
          },
          "autocomplete_version_number_tokenizer": {
            "max_gram": 20,
            "min_gram": 2,
            "token_chars": [
              "letter",
              "digit",
              "punctuation"
            ],
            "type": "edge_ngram"
          }
        },
        "normalizer": {
          "case_insensitive": {
            "type": "custom",
            "char_filter": [],
            "filter": ["lowercase", "asciifolding"]
          }
        }
      },
      "index": {
        "refresh_interval": "1s",
        "number_of_shards": "5",
        "max_inner_result_window": 10000
      }
    },
    "mappings": {
        "properties": {
          "controls_sums": {
            "properties": {
              "failed": {
                "properties": {
                  "critical": {
                    "type": "integer"
                  },
                  "major": {
                    "type": "integer"
                  },
                  "minor": {
                    "type": "integer"
                  },
                  "total": {
                    "type": "integer"
                  }
                },
                "type": "object"
              },
              "passed": {
                "properties": {
                  "total": {
                    "type": "integer"
                  }
                },
                "type": "object"
              },
              "skipped": {
                "properties": {
                  "total": {
                    "type": "integer"
                  }
                },
                "type": "object"
              },
              "waived": {
                "properties": {
                  "total": {
                    "type": "integer"
                  }
                },
                "type": "object"
              },
              "total": {
                "type": "integer"
              }
            },
            "type": "object"
          },
          "daily_latest": {
            "type": "boolean"
          },
          "day_latest": {
            "type": "boolean"
          },
          "depends": {
            "type": "object",
            "properties": {
            "name": {
                "type": "keyword"
              },
              "path": {
                "type": "keyword"
          },
          "status": {
            "type": "keyword"
          },
          "skip_message": {
            "type": "keyword"
          }
        }
      },
          "doc_version": {
            "type": "keyword"
          },
          "end_time": {
            "type": "date"
          },
          "environment": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "job_uuid": {
            "type": "keyword"
          },
          "node_name": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "node_uuid": {
            "type": "keyword"
          },
          "other_checks": {
            "type": "keyword"
          },
          "platform": {
            "properties": {
              "name": {
                "fields": {
                  "engram": {
                    "analyzer": "autocomplete",
                    "type": "text"
                  },
                  "lower": {
                    "normalizer": "case_insensitive",
                    "type": "keyword"
                  }
                },
                "type": "keyword"
              },
              "release": {
                "fields": {
                  "engram": {
                    "analyzer": "autocomplete",
                    "type": "text"
                  },
                  "lower": {
                    "normalizer": "case_insensitive",
                    "type": "keyword"
                  }
                },
                "type": "keyword"
              },
              "full": {
                "fields": {
                  "engram": {
                    "analyzer": "autocomplete_version_numbers",
                    "type": "text"
                  },
                  "lower": {
                    "normalizer": "case_insensitive",
                    "type": "keyword"
                  }
                },
                "type": "keyword"
              }
            }
          },
          "profiles": {
            "properties": {
              "controls": {
                "properties": {
                  "id": {
                    "type": "keyword"
                  },
                  "impact": {
                    "type": "double"
                  },
                  "title": {
                    "type": "keyword",
                    "fields": {
                      "engram": {
                        "type": "text",
                        "analyzer": "autocomplete"
                      },
                      "lower": {
                        "normalizer": "case_insensitive",
                        "type": "keyword"
                      }
                    }
                  },
                  "refs": {
                    "type": "nested",
                    "properties": {
                      "key": {
                        "type": "keyword"
                      },
                      "values": {
                        "type": "keyword"
                      }
                    }
                  },
                  "string_tags": {
                    "type": "nested",
                    "properties": {
                      "key": {
                        "type": "keyword",
                        "fields": {
                          "engram": {
                            "type": "text",
                            "analyzer": "autocomplete"
                          },
                          "lower": {
                            "type": "keyword",
                            "normalizer": "case_insensitive"
                          }
                        }
                      },
                      "values": {
                        "type": "keyword",
                        "fields": {
                          "engram": {
                            "type": "text",
                            "analyzer": "autocomplete"
                          },
                          "lower": {
                            "type": "keyword",
                            "normalizer": "case_insensitive"
                          }
                        }
                      }
                    }
                  },
                  "waiver_data": {
                    "type": "object",
                    "properties": {
                      "expiration_date": {
                        "type": "keyword"
                      },
                      "justification": {
                        "type": "keyword"
                      },
                      "run": {
                        "type": "boolean"
                      },
                      "skipped_due_to_waiver": {
                        "type": "boolean"
                      },
                      "message": {
                        "type": "keyword"
                      }
                    }
                  },
                  "waived_str": {
                    "type": "keyword"
                  },
                  "results": {
                    "properties": {
                      "code_desc": {
                        "type": "keyword"
                      },
                      "run_time": {
                        "type": "double"
                      },
                      "status": {
                        "type": "keyword"
                      }
                    }
                  },
                  "status": {
                    "type": "keyword"
                  },
                  "removed_results_counts": {
                    "properties": {
                      "failed": {
                        "type": "integer"
                      },
                      "skipped": {
                        "type": "integer"
                      },
                      "passed": {
                        "type": "integer"
                      }
                    },
                    "type": "object"
                  }
                },
                "type": "nested"
              },
              "controls_sums": {
                "properties": {
                  "failed": {
                    "properties": {
                      "critical": {
                        "type": "integer"
                      },
                      "major": {
                        "type": "integer"
                      },
                      "minor": {
                        "type": "integer"
                      },
                      "total": {
                        "type": "integer"
                      }
                    },
                    "type": "object"
                  },
                  "passed": {
                    "properties": {
                      "total": {
                        "type": "integer"
                      }
                    },
                    "type": "object"
                  },
                  "skipped": {
                    "properties": {
                      "total": {
                        "type": "integer"
                      }
                    },
                    "type": "object"
                  },
                  "waived": {
                    "properties": {
                      "total": {
                        "type": "integer"
                      }
                    },
                    "type": "object"
                  },
                  "total": {
                    "type": "integer"
                  }
                },
                "type": "object"
              },
              "name": {
                "type": "keyword"
              },
              "title": {
                "type": "keyword",
                "fields": {
                  "engram": {
                    "type": "text",
                    "analyzer": "autocomplete"
                  },
                  "lower": {
                    "normalizer": "case_insensitive",
                    "type": "keyword"
                  }
                }
              },
              "profile": {
                "type": "keyword"
              },
              "sha256": {
                "type": "keyword"
              },
              "skip_message": {
                "type": "keyword"
              },
              "status_message": {
                "type": "keyword"
              },
              "status": {
                "type": "keyword"
              },
              "version": {
                "type": "keyword"
              },
              "full": {
                "fields": {
                  "engram": {
                    "analyzer": "autocomplete_version_numbers",
                    "type": "text"
                  },
                  "lower": {
                    "normalizer": "case_insensitive",
                    "type": "keyword"
                  }
                },
                "type": "keyword"
              }
            },
            "type": "nested"
          },
          "recipes": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "report_uuid": {
            "type": "keyword"
          },
          "roles": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "statistics": {
            "properties": {
              "duration": {
                "type": "double"
              }
            }
          },
          "status": {
            "type": "keyword"
          },
          "projects": {
            "type": "keyword"
          },
          "version": {
            "type": "keyword",
            "fields": {
              "engram": {
                "type": "text",
                "analyzer": "autocomplete_version_numbers"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            }
          },
      "policy_name": {
        "fields": {
          "engram": {
            "analyzer": "autocomplete",
            "type": "text"
          },
          "lower": {
            "normalizer": "case_insensitive",
            "type": "keyword"
          }
        },
        "type": "keyword"
      },
      "policy_group": {
        "fields": {
          "engram": {
            "analyzer": "autocomplete",
            "type": "text"
          },
          "lower": {
            "normalizer": "case_insensitive",
            "type": "keyword"
          }
        },
        "type": "keyword"
      },
      "organization_name": {
        "fields": {
          "engram": {
            "analyzer": "autocomplete",
            "type": "text"
          },
          "lower": {
            "normalizer": "case_insensitive",
            "type": "keyword"
          }
        },
        "type": "keyword"
      },
      "source_fqdn": {
        "fields": {
          "engram": {
            "analyzer": "autocomplete",
            "type": "text"
          },
          "lower": {
            "normalizer": "case_insensitive",
            "type": "keyword"
          }
        },
        "type": "keyword"
      },
      "chef_tags": {
        "fields": {
          "engram": {
            "analyzer": "autocomplete",
            "type": "text"
          },
          "lower": {
            "normalizer": "case_insensitive",
            "type": "keyword"
          }
        },
        "type": "keyword"
      },
      "ipaddress": {
        "type": "ip"
      },
      "fqdn": {
        "type": "keyword",
        "doc_values": false,
        "ignore_above": 256
      },
      "run_time_limit": {
        "type": "double"
      },
      "status_message": {
        "type": "keyword"
      }
        }
    }
  }`,
}

Compliance mapping used to create the `comp-<version>-r-<date>` index

View Source
var ComplianceRunInfo = Mapping{
	Index:      IndexNameComplianceRunInfo,
	Timeseries: false,
	Mapping: `
    {
    "index_patterns": ["` + IndexNameComplianceRunInfo + `"],
    "settings": {
        "index": {
            "refresh_interval": "1s",
            "number_of_shards": "5"
        },
        "analysis": {
            "analyzer": {
                "autocomplete": {
                    "filter": [
                        "lowercase"
                    ],
                    "tokenizer": "autocomplete_tokenizer"
                },
                "autocomplete_version_numbers": {
                    "filter": [
                        "lowercase"
                    ],
                    "tokenizer": "autocomplete_version_number_tokenizer"
                }
            },
            "tokenizer": {
                "autocomplete_tokenizer": {
                    "max_gram": 20,
                    "min_gram": 2,
                    "token_chars": [
                        "letter",
                        "digit"
                    ],
                    "type": "edge_ngram"
                },
                "autocomplete_version_number_tokenizer": {
                    "max_gram": 20,
                    "min_gram": 2,
                    "token_chars": [
                        "letter",
                        "digit",
                        "punctuation"
                    ],
                    "type": "edge_ngram"
                }
            },
            "normalizer": {
                "case_insensitive": {
                    "type": "custom",
                    "char_filter": [],
                    "filter": [
                        "lowercase",
                        "asciifolding"
                    ]
                }
            }
        }
    },
    "mappings": {
        "properties": {
            "node_uuid": {
                "type": "keyword"
            },
            "resource_uuid": {
                "type": "keyword"
            },
            "resource_type": {
                "type": "keyword"
            },
            "status": {
                "type": "keyword"
            },
            "first_run": {
                "type": "date"
            },
            "last_run": {
                "type": "date"
            },
            "chef_server": {
                "type": "keyword",
                "fields": {
                    "engram": {
                        "type": "text",
                        "analyzer": "autocomplete"
                    },
                    "lower": {
                        "type": "keyword",
                        "normalizer": "case_insensitive"
                    }
                }
            },
            "organization": {
                "type": "keyword",
                "fields": {
                    "engram": {
                        "type": "text",
                        "analyzer": "autocomplete"
                    },
                    "lower": {
                        "type": "keyword",
                        "normalizer": "case_insensitive"
                    }
                }
            },
            "environment": {
                "fields": {
                    "engram": {
                        "analyzer": "autocomplete",
                        "type": "text"
                    },
                    "lower": {
                        "normalizer": "case_insensitive",
                        "type": "keyword"
                    }
                },
                "type": "keyword"
            },
            "version": {
                "type": "keyword",
                "fields": {
                    "engram": {
                        "type": "text",
                        "analyzer": "autocomplete_version_numbers"
                    },
                    "lower": {
                        "type": "keyword",
                        "normalizer": "case_insensitive"
                    }
                }
            },
            "policy_name": {
                "type": "keyword",
                "fields": {
                    "engram": {
                        "type": "text",
                        "analyzer": "autocomplete"
                    },
                    "lower": {
                        "type": "keyword",
                        "normalizer": "case_insensitive"
                    }
                }
            },
            "policy_group": {
                "type": "keyword",
                "fields": {
                    "engram": {
                        "type": "text",
                        "analyzer": "autocomplete"
                    },
                    "lower": {
                        "type": "keyword",
                        "normalizer": "case_insensitive"
                    }
                }
            },
            "profiles": {
                "type": "nested",
                "properties": {
                    "controls": {
                        "type": "nested",
                        "properties": {
                            "id": {
                                "type": "keyword"
                            },
                            "control_tags": {
                                "type": "nested",
                                "properties": {
                                    "key": {
                                        "type": "keyword",
                                        "fields": {
                                            "engram": {
                                                "type": "text",
                                                "analyzer": "autocomplete"
                                            },
                                            "lower": {
                                                "type": "keyword",
                                                "normalizer": "case_insensitive"
                                            }
                                        }
                                    },
                                    "values": {
                                        "type": "keyword",
                                        "fields": {
                                            "engram": {
                                                "type": "text",
                                                "analyzer": "autocomplete"
                                            },
                                            "lower": {
                                                "type": "keyword",
                                                "normalizer": "case_insensitive"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "title": {
                        "type": "keyword",
                        "fields": {
                            "engram": {
                                "type": "text",
                                "analyzer": "autocomplete"
                            },
                            "lower": {
                                "type": "keyword",
                                "normalizer": "case_insensitive"
                            }
                        }
                    },
                    "sha256": {
                        "type": "keyword"
                    },
                    "name": {
                        "type": "keyword"
                    },
                    "full": {
                        "type": "keyword",
                        "fields": {
                            "engram": {
                                "type": "text",
                                "analyzer": "autocomplete_version_numbers"
                            },
                            "lower": {
                                "type": "keyword",
                                "normalizer": "case_insensitive"
                            }
                        }
                    }
                }
            },
            "recipes": {
                "type": "keyword",
                "fields": {
                    "engram": {
                        "type": "text",
                        "analyzer": "autocomplete"
                    },
                    "lower": {
                        "type": "keyword",
                        "normalizer": "case_insensitive"
                    }
                }
            },
            "roles": {
                "type": "keyword",
                "fields": {
                    "engram": {
                        "type": "text",
                        "analyzer": "autocomplete"
                    },
                    "lower": {
                        "type": "keyword",
                        "normalizer": "case_insensitive"
                    }
                }
            },
            "platform_version": {
                "properties": {
                    "full": {
                        "type": "keyword",
                        "fields": {
                            "engram": {
                                "type": "text",
                                "analyzer": "autocomplete_version_numbers"
                            },
                            "lower": {
                                "type": "keyword",
                                "normalizer": "case_insensitive"
                            }
                        }
                    },
                    "name": {
                        "type": "keyword",
                        "fields": {
                            "engram": {
                                "type": "text",
                                "analyzer": "autocomplete"
                            },
                            "lower": {
                                "type": "keyword",
                                "normalizer": "case_insensitive"
                            }
                        }
                    },
                    "release": {
                        "type": "keyword",
                        "fields": {
                            "engram": {
                                "type": "text",
                                "analyzer": "autocomplete"
                            },
                            "lower": {
                                "type": "keyword",
                                "normalizer": "case_insensitive"
                            }
                        }
                    }
                }
            },
            "chef_tags": {
                "fields": {
                    "engram": {
                        "analyzer": "autocomplete",
                        "type": "text"
                    },
                    "lower": {
                        "normalizer": "case_insensitive",
                        "type": "keyword"
                    }
                },
                "type": "keyword"
            }
        }
    }
}
	`,
}

ComplianceRunInfo mapping used to create the `compliance-run-info index

View Source
var ComplianceSumDate = Mapping{
	Index:      IndexNameSum,
	Timeseries: true,
	Mapping: `
  {
    "index_patterns": ["` + IndexNameSum + `-20*"],
    "settings": {
      "analysis": {
        "analyzer": {
          "autocomplete": {
            "filter": [
              "lowercase"
            ],
            "tokenizer": "autocomplete_tokenizer"
          },
          "autocomplete_version_numbers": {
            "filter": [
              "lowercase"
            ],
            "tokenizer": "autocomplete_version_number_tokenizer"
          }
        },
        "tokenizer": {
          "autocomplete_tokenizer": {
            "max_gram": 20,
            "min_gram": 2,
            "token_chars": [
              "letter",
              "digit"
            ],
            "type": "edge_ngram"
          },
          "autocomplete_version_number_tokenizer": {
            "max_gram": 20,
            "min_gram": 2,
            "token_chars": [
              "letter",
              "digit",
              "punctuation"
            ],
            "type": "edge_ngram"
          }
        },
        "normalizer": {
          "case_insensitive": {
            "type": "custom",
            "char_filter": [],
            "filter": ["lowercase", "asciifolding"]
          }
        }
      },
      "index": {
        "refresh_interval": "1s",
        "number_of_shards": "5"
      }
    },
    "mappings": {
        "properties": {
          "controls_sums": {
            "properties": {
              "failed": {
                "properties": {
                  "critical": {
                    "type": "integer"
                  },
                  "major": {
                    "type": "integer"
                  },
                  "minor": {
                    "type": "integer"
                  },
                  "total": {
                    "type": "integer"
                  }
                },
                "type": "object"
              },
              "passed": {
                "properties": {
                  "total": {
                    "type": "integer"
                  }
                },
                "type": "object"
              },
              "skipped": {
                "properties": {
                  "total": {
                    "type": "integer"
                  }
                },
                "type": "object"
              },
              "waived": {
                "properties": {
                  "total": {
                    "type": "integer"
                  }
                },
                "type": "object"
              },
              "total": {
                "type": "integer"
              }
            },
            "type": "object"
          },
          "daily_latest": {
            "type": "boolean"
          },
          "day_latest": {
            "type": "boolean"
          },
          "doc_version": {
            "type": "keyword"
          },
          "end_time": {
            "type": "date"
          },
          "environment": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "job_uuid": {
            "type": "keyword"
          },
          "node_name": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "node_uuid": {
            "type": "keyword"
          },
          "platform": {
            "properties": {
              "name": {
                "fields": {
                  "engram": {
                    "analyzer": "autocomplete",
                    "type": "text"
                  },
                  "lower": {
                    "normalizer": "case_insensitive",
                    "type": "keyword"
                  }
                },
                "type": "keyword"
              },
              "release": {
                "fields": {
                  "engram": {
                    "analyzer": "autocomplete",
                    "type": "text"
                  },
                  "lower": {
                    "normalizer": "case_insensitive",
                    "type": "keyword"
                  }
                },
                "type": "keyword"
              },
              "full": {
                "fields": {
                  "engram": {
                    "analyzer": "autocomplete_version_numbers",
                    "type": "text"
                  },
                  "lower": {
                    "normalizer": "case_insensitive",
                    "type": "keyword"
                  }
                },
                "type": "keyword"
              }
            }
          },
          "profiles": {
            "properties": {
              "controls_sums": {
                "properties": {
                  "failed": {
                    "properties": {
                      "critical": {
                        "type": "integer"
                      },
                      "major": {
                        "type": "integer"
                      },
                      "minor": {
                        "type": "integer"
                      },
                      "total": {
                        "type": "integer"
                      }
                    },
                    "type": "object"
                  },
                  "passed": {
                    "properties": {
                      "total": {
                        "type": "integer"
                      }
                    },
                    "type": "object"
                  },
                  "skipped": {
                    "properties": {
                      "total": {
                        "type": "integer"
                      }
                    },
                    "type": "object"
                  },
                  "waived": {
                    "properties": {
                      "total": {
                        "type": "integer"
                      }
                    },
                    "type": "object"
                  },
                  "total": {
                    "type": "integer"
                  }
                },
                "type": "object"
              },
              "profile": {
                "type": "keyword"
              },
              "name": {
                "type": "keyword"
              },
              "title": {
                "type": "keyword",
                "fields": {
                  "engram": {
                    "type": "text",
                    "analyzer": "autocomplete"
                  },
                  "lower": {
                    "normalizer": "case_insensitive",
                    "type": "keyword"
                  }
                }
              },
              "sha256": {
                "type": "keyword"
              },
              "version": {
                "type": "keyword"
              },
              "status": {
                "type": "keyword"
              },
              "full": {
                "fields": {
                  "engram": {
                    "analyzer": "autocomplete_version_numbers",
                    "type": "text"
                  },
                  "lower": {
                    "normalizer": "case_insensitive",
                    "type": "keyword"
                  }
                },
                "type": "keyword"
              }
            },
            "type": "nested"
          },
          "recipes": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "report_uuid": {
            "type": "keyword"
          },
          "roles": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "status": {
            "type": "keyword"
          },
          "status_message": {
            "type": "keyword"
          },
          "projects": {
            "type": "keyword"
          },
          "statistics": {
            "properties": {
              "duration": {
                "type": "double"
              }
            }
          },
          "version": {
            "type": "keyword",
            "fields": {
              "engram": {
                "type": "text",
                "analyzer": "autocomplete_version_numbers"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            }
          },
          "policy_name": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "policy_group": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "organization_name": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "source_fqdn": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          },
          "chef_tags": {
            "fields": {
              "engram": {
                "analyzer": "autocomplete",
                "type": "text"
              },
              "lower": {
                "normalizer": "case_insensitive",
                "type": "keyword"
              }
            },
            "type": "keyword"
          }
        }
    }
  }`,
}

Compliance mapping used to create the `comp-<version>-s-<date>` index

Functions

This section is empty.

Types

type Mapping

type Mapping struct {
	Index      string
	Alias      string
	Timeseries bool
	Mapping    string
}

Mapping type is the representation of an ES mapping, it contains all the necessary fields you need to create a mapping and to insert documents to it

func (*Mapping) IndexTimeseriesFmt

func (m *Mapping) IndexTimeseriesFmt(date time.Time) string

Index will return the name of the index plus a date string associated to the Mapping. The format will be (index-name) -YYYY.MM.DD

func (*Mapping) IndexTimeseriesScanDate

func (m *Mapping) IndexTimeseriesScanDate(indexName string) (time.Time, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL