// ComputeGapAnalysis will compute the gap analysis and return the inventory of the controls for the
// opencontrol workspace if successful. Otherwise, it will return a list of error messages.
// TODO: fix the error return to return of type error. This was used because existing code returned that type
// TODO: e.g. GetCertification
func ComputeGapAnalysis(config Config) (Inventory, []error) {
	// Initialize inventory with certification
	certificationPath, errs := certifications.GetCertification(config.OpencontrolDir, config.Certification)
	if certificationPath == "" {
		return Inventory{}, errs
	}
	openControlData, _ := models.LoadData(config.OpencontrolDir, certificationPath)
	i := Inventory{
		OpenControl:             openControlData,
		masterControlList:       make(map[string]models.Control),
		actualSatisfiedControls: make(map[string]base.Satisfies),
		MissingControlList:      make(map[string]models.Control),
	}
	if i.Certification == nil || i.Components == nil {
		return Inventory{}, []error{fmt.Errorf("Unable to load data in %s for certification %s", config.OpencontrolDir, config.Certification)}
	}

	// Gather list of all controls for certification
	i.retrieveMasterControlsList()
	// Find the documented controls.
	i.findDocumentedControls()
	// Calculate the Missing controls / Non documented
	i.calculateNonDocumentedControls()

	return i, nil
}
Beispiel #2
0
// MakeGitbook is the wrapper function that will create a gitbook for the specified certification.
func MakeGitbook(config gitbook.Config) (string, []error) {
	warning := ""
	certificationPath, err := certifications.GetCertification(config.OpencontrolDir, config.Certification)
	if certificationPath == "" {
		return warning, err
	}
	if _, err := os.Stat(config.MarkdownPath); os.IsNotExist(err) {
		warning = "Warning: markdown directory does not exist"
	}
	config.Certification = certificationPath
	if err := config.BuildGitbook(); err != nil {
		return warning, err
	}
	return warning, nil
}