mappings

package
v0.0.0-...-0490640 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

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 = "3"
	//ComplianceCurrentProfilesIndicesVersion allows us to know, for any version of compliance, what level we are at with our profiles and profiles-mappings indices
	ComplianceCurrentProfilesIndicesVersion = "3"
	ComplianceCurrentFeedsIndicesVersion    = "2"

	DocType        = "_doc"
	IndexNameProf  = compAndVersionProfiles + "-profiles"
	IndexNameFeeds = compAndVersionFeeds + "-feeds"

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

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 ComplianceFeeds = Mapping{
	Index:      IndexNameFeeds,
	Type:       DocType,
	Timeseries: false,
	Mapping: `
		{
		  "template" : "` + IndexNameFeeds + `",
		  "settings": {
			"index": {
			  "refresh_interval": "1s"
			}
		  },
		  "mappings": {
			"` + DocType + `": {
                                "properties" : {
                                    "entity_uuid" : 					{ "type" : "keyword" },
									"producer_id" :						{ "type" : "keyword" },
									"producer_name" :					{ "type" : "text" },
									"producer_object_type" :			{ "type" : "text" },
									"producer_tags" : 					{ "type" : "keyword" },
									"feed_type" : 						{ "type" : "text" },
									"event_type" : 						{ "type" : "keyword" },
									"tags" : 							{
																			"type" : "keyword",
																			"fields" : {
																				"keyword" : {
																				"type" : "keyword",
																				"ignore_above" : 256
																				}
																			}
																		},
									"pub_timestamp" : 					{ "type" : "date", "format" : "strict_date_optional_time||epoch_millis" },
									"actor_id" : 						{ "type" : "text" },
									"actor_name" : 						{ "type" : "text" },
									"actor_object_type" : 				{ "type" : "text" },
									"verb" : 							{ "type" : "keyword" },
									"object_id" : 						{ "type" : "text" },
									"object_name" : 					{ "type" : "text" },
									"object_object_type" : 				{ "type" : "keyword" },
									"target_id" : 						{ "type" : "text" },
									"target_name" : 					{ "type" : "text" },
									"target_object_type" : 				{ "type" : "text" },
									"created" :							{ "type" : "date", "format" : "strict_date_optional_time||epoch_millis" }
                                }
                            }
			}
		}`,
}

ComplianceFeeds mapping used to create the comp-[version]-feeds index

View Source
var ComplianceProfiles = Mapping{
	Index:      IndexNameProf,
	Type:       DocType,
	Timeseries: false,
	Mapping: `
{
  "template": "` + IndexNameProf + `",
  "settings": {
    "index": {
      "refresh_interval": "1s"
    },
    "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": {
    "` + DocType + `": {
      "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,
	Type:       DocType,
	Timeseries: true,
	Mapping: `
{
  "index_patterns": ["` + IndexNameRep + `-20*"],
  "settings": {
    "analysis": {
      "analyzer": {
        "autocomplete": {
          "filter": [
            "lowercase"
          ],
          "tokenizer": "autocomplete_tokenizer"
        }
      },
      "tokenizer": {
        "autocomplete_tokenizer": {
          "max_gram": 20,
          "min_gram": 2,
          "token_chars": [
            "letter",
            "digit"
          ],
          "type": "edge_ngram"
        }
      },
      "normalizer": {
        "case_insensitive": {
          "type": "custom",
          "char_filter": [],
          "filter": ["lowercase", "asciifolding"]
        }
      }
    },
    "index": {
      "refresh_interval": "1s"
    }
  },
  "mappings": {
    "` + DocType + `": {
      "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"
            },
            "total": {
              "type": "integer"
            }
          },
          "type": "object"
        },
        "daily_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": {
              "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"
                    }
                  }
                },
                "results": {
                  "properties": {
                    "code_desc": {
                      "type": "keyword"
                    },
                    "run_time": {
                      "type": "double"
                    },
                    "status": {
                      "type": "keyword"
                    }
                  }
                },
                "status": {
                  "type": "keyword"
                }
              },
              "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"
								},
								"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": {
              "type": "keyword"
            },
            "version": {
              "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"
            },
            "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
				}
      }
    }
  }
}`,
}

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

View Source
var ComplianceSumDate = Mapping{
	Index:      IndexNameSum,
	Type:       DocType,
	Timeseries: true,
	Mapping: `
{
  "index_patterns": ["` + IndexNameSum + `-20*"],
  "settings": {
    "analysis": {
      "analyzer": {
        "autocomplete": {
          "filter": [
            "lowercase"
          ],
          "tokenizer": "autocomplete_tokenizer"
        }
      },
      "tokenizer": {
        "autocomplete_tokenizer": {
          "max_gram": 20,
          "min_gram": 2,
          "token_chars": [
            "letter",
            "digit"
          ],
          "type": "edge_ngram"
        }
      },
      "normalizer": {
        "case_insensitive": {
          "type": "custom",
          "char_filter": [],
          "filter": ["lowercase", "asciifolding"]
        }
      }
    },
    "index": {
      "refresh_interval": "1s"
    }
  },
  "mappings": {
    "` + DocType + `": {
      "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"
            },
            "total": {
              "type": "integer"
            }
          },
          "type": "object"
        },
        "daily_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": {
              "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"
                },
                "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"
            }
          },
          "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"
        },
        "projects": {
          "type": "keyword"
        },
        "statistics": {
          "properties": {
            "duration": {
              "type": "double"
            }
          }
        },
        "version": {
          "type": "keyword",
          "fields": {
            "engram": {
              "type": "text",
              "analyzer": "autocomplete"
            },
            "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
	Type       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

Jump to

Keyboard shortcuts

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