// Executes the rule check using the "-C" flag
16472
func (runner *runner) checkRuleUsingCheck(args []string) (bool, error) {
	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
	defer cancel()

	out, err := runner.runContext(ctx, opCheckRule, args)
	if ctx.Err() == context.DeadlineExceeded {
		return false, fmt.Errorf("timed out while checking rules")
	}
	if err == nil {
		return true, nil
	}
	if ee, ok := err.(utilexec.ExitError); ok {
		// iptables uses exit(1) to indicate a failure of the operation,
		// as compared to a malformed commandline, for example.
		if ee.Exited() && ee.ExitStatus() == 1 {
			return false, nil
		}
	}
	return false, fmt.Errorf("error checking rule: %v: %s", err, out)
}
33430
func (mr *MatchRules) RuleMatching(r *Rule) (abort bool, err error) {
	metas := r.Metas()
	// convert int to int32 for code that relies on previous behavior
	for s := range metas {
		if i, ok := metas[s].(int); ok {
			metas[s] = int32(i)
		}
	}
	*mr = append(*mr, MatchRule{
		Rule:      r.Identifier(),
		Namespace: r.Namespace(),
		Tags:      r.Tags(),
		Meta:      metas,
		Strings:   r.getMatchStrings(),
	})
	return
}
890434
func ruleError(c ErrorCode, desc string) RuleError {
	return RuleError{ErrorCode: c, Description: desc}
}
139933
func (ca *CertAuthorityV2) Check() error {
	err := ca.ID().Check()
	if err != nil {
		return trace.Wrap(err)
	}
	_, err = ca.Checkers()
	if err != nil {
		return trace.Wrap(err)
	}
	_, err = ca.Signers()
	if err != nil {
		return trace.Wrap(err)
	}
	// This is to force users to migrate
	if len(ca.Spec.Roles) != 0 && len(ca.Spec.RoleMap) != 0 {
		return trace.BadParameter("should set either 'roles' or 'role_map', not both")
	}
	if err := RoleMap(ca.Spec.RoleMap).Check(); err != nil {
		return trace.Wrap(err)
	}
	return nil
}
764163
func (c *Container) check() error {
	var a ErrorList

	if c.isArray() {
		array := c.array()
		if int32(len(array)) != c.n {
			a.Append(fmt.Errorf("array count mismatch: count=%d, n=%d", len(array), c.n))
		}
	} else if c.isRun() {
		n := c.runCountRange(0, maxContainerVal+1)
		if n != c.n {
			a.Append(fmt.Errorf("run count mismatch: count=%d, n=%d", n, c.n))
		}
	} else if c.isBitmap() {
		if n := c.bitmapCountRange(0, maxContainerVal+1); n != c.n {
			a.Append(fmt.Errorf("bitmap count mismatch: count=%d, n=%d", n, c.n))
		}
	} else {
		a.Append(fmt.Errorf("empty container"))
		if c.n != 0 {
			a.Append(fmt.Errorf("empty container with nonzero count: n=%d", c.n))
		}
	}

	if a == nil {
		return nil
	}
	return a
}
1075139
func Check(d *certdata.Data) *errors.Errors {
	var e = errors.New(nil)

	// OCSP signing certificates should not contain an OCSP server
	if d.Type == "OCSP" {
		if len(d.Cert.OCSPServer) > 0 {
			e.Warning("OCSP signing certificate contains an OCSP server")
		}

		// no extra checks needed
		return e
	}

	// Self signed CA certificates should not contain any revocation sources
	if d.Type == "CA" && d.Cert.CheckSignatureFrom(d.Cert) == nil {
		if len(d.Cert.CRLDistributionPoints) != 0 && len(d.Cert.OCSPServer) != 0 {
			e.Warning("Self signed CA certificates should not contain any revocation sources")
		}
		return e
	}

	if len(d.Cert.CRLDistributionPoints) == 0 && len(d.Cert.OCSPServer) == 0 {
		e.Err("Certificate contains no CRL or OCSP server")
		return e
	}

	// Check CRL information
	for _, crl := range d.Cert.CRLDistributionPoints {
		l, err := url.Parse(crl)
		if err != nil {
			e.Err("Certificate contains an invalid CRL (%s)", crl)
		} else if l.Scheme != "http" {
			e.Err("Certificate contains a CRL with an non-preferred scheme (%s)", l.Scheme)
		}
	}

	// Check OCSP information
	for _, server := range d.Cert.OCSPServer {
		s, err := url.Parse(server)
		if err != nil {
			e.Err("Certificate contains an invalid OCSP server (%s)", s)
		} else if s.Scheme != "http" {
			e.Err("Certificate contains a OCSP server with an non-preferred scheme (%s)", s.Scheme)
		}
	}

	return e
}
741900
func (darwin *darwinRecord) checkRunning() (string, bool) {
	output, err := exec.Command("launchctl", "list", darwin.name).Output()
	if err == nil {
		if matched, err := regexp.MatchString(darwin.name, string(output)); err == nil && matched {
			reg := regexp.MustCompile("PID\" = ([0-9]+);")
			data := reg.FindStringSubmatch(string(output))
			if len(data) > 1 {
				return "Service (pid  " + data[1] + ") is running...", true
			}
			return "Service is running...", true
		}
	}

	return "Service is stopped", false
}
762746
func main() {
	flag.Parse()

	specfname, e := getSpecFileName("compliance.prop")
	if e != nil {
		log.Println("error -", e)
	}
	rmspec, e1 := readCommandsFromSpecFile(specfname)
	if e1 != nil {
		log.Println("error -", e1)
		return
	}

	var rctype clientType

	fmt.Println()
	fmt.Println("/////////////////////////////////////")
	fmt.Println("///  Go-Redis client compliance   ///")
	fmt.Println("/////////////////////////////////////\n")

	rctype = sync
	analyzeAndReport(rctype, rmspec)

	rctype = async
	analyzeAndReport(rctype, rmspec)
}
234281
func (l *loop) checkTermination(reason interface{}) {
	switch {
	case reason == nil:
		// Regular end.
		l.status = Stopping
	case l.recoverF == nil:
		// Error but no recover function.
		l.status = Stopping
		if l.err != nil {
			break
		}
		if err, ok := reason.(error); ok {
			l.err = err
		} else {
			l.err = errors.New(ErrLoopPanicked, errorMessages, reason)
		}
	default:
		// Try to recover.
		logger.Errorf("loop %q tries to recover", l)
		l.recoverings = append(l.recoverings, &Recovering{time.Now(), reason})
		l.recoverings, l.err = l.recoverF(l.recoverings)
		if l.err != nil {
			l.status = Stopping
		} else {
			l.logf(false, "loop %q recovered", l)
		}
	}
}
1287307
func check(err error) {
	if err != nil {
		b := make([]byte, 2<<10)
		b = b[:runtime.Stack(b, false)]
		log.Printf("Unlikely error condition triggered: %v at %s", err, b)
		panic(err)
	}
}
1198275
func (s State) CheckValid() error {
	switch s {
	case StateNew, StateStart, StateClose:
		return nil
	default:
		return errors.NewBadParameterError("iteration state", s).Expected(StateNew + "|" + StateStart + "|" + StateClose)
	}
}
75136
func (a *Automaton) IsAccept(state int) bool {
	return a.isAccept.Get(int64(state))
}
918979
func (g *GopathTest) Check(err error) {
	if err == nil {
		return
	}
	g.Fatal(err)
}
1019811
func Check() []Result {
	results := make([]Result, 0, len(checkers))
	for _, checker := range checkers {
		startTime := time.Now()
		if raw, err := checker.check(); err != nil && err != ErrDisabledComponent {
			results = append(results, Result{
				Name:     checker.name,
				Raw:      raw,
				Status:   "fail - " + err.Error(),
				Duration: time.Now().Sub(startTime),
			})
		} else if err == nil {
			results = append(results, Result{
				Name:     checker.name,
				Raw:      raw,
				Status:   HealthCheckOK,
				Duration: time.Now().Sub(startTime),
			})
		}
	}
	return results
}
1130498
func ArgumentCheck(l *State, cond bool, index int, extraMessage string) {
	if !cond {
		ArgumentError(l, index, extraMessage)
	}
}
275154
func (hc *Check) execute() *Result {
	ch := make(chan *Result, 1)
	checker := hc.Checker
	go func() {
		// TODO(jsing): Determine a way to ensure that this go routine
		// does not linger.
		ch <- checker.Check(hc.Timeout)
	}()
	select {
	case result := <-ch:
		return result
	case <-time.After(hc.Timeout):
		return &Result{"Timed out", false, hc.Timeout, nil}
	}
}
508670
func (c *txIDOptions) Check() error {
	if len(c.TxID) != 64 {
		return ErrInvalidTxID
	}
	if _, err := hex.DecodeString(c.TxID); err != nil {
		return ErrInvalidTxID
	}
	return nil
}