repochecker/epita: Check full numbered flag has type number
This commit is contained in:
parent
7b2603afb0
commit
79c251d85f
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
|
@ -24,7 +25,11 @@ func EPITACheckKeyFlag(flag *fic.FlagKey, raw string, exceptions *sync.CheckExce
|
|||
errs = append(errs, fmt.Errorf("CVE numbers are required to be UCQ with choice_cost"))
|
||||
}
|
||||
|
||||
if flag.Placeholder == "" && (flag.Type == "text" || (flag.Type == "ucq" && flag.ChoicesCost > 0)) {
|
||||
if _, err := strconv.ParseInt(raw, 10, 64); flag.Type == "key" && err == nil && !exceptions.HasException(":not-number-flag") {
|
||||
errs = append(errs, fmt.Errorf("shouldn't be this flag a number type? (:not-number-flag)"))
|
||||
}
|
||||
|
||||
if flag.Placeholder == "" && (strings.HasPrefix(flag.Type, "number") || flag.Type == "key" || flag.Type == "text" || (flag.Type == "ucq" && flag.ChoicesCost > 0)) {
|
||||
errs = append(errs, fmt.Errorf("no placeholder defined"))
|
||||
}
|
||||
|
||||
|
@ -43,10 +48,12 @@ func EPITACheckKeyFlag(flag *fic.FlagKey, raw string, exceptions *sync.CheckExce
|
|||
}
|
||||
|
||||
func EPITACheckKeyFlagWithChoices(flag *fic.FlagKey, raw string, choices []*fic.FlagChoice, exceptions *sync.CheckExceptions) (errs []error) {
|
||||
if len(choices) < 10 && flag.ChoicesCost == 0 {
|
||||
errs = append(errs, fmt.Errorf("requires at least 10 choices to avoid brute-force"))
|
||||
} else if len(choices) < 6 && flag.ChoicesCost > 0 {
|
||||
errs = append(errs, fmt.Errorf("requires at least 10 choices to avoid brute-force"))
|
||||
if !exceptions.HasException(":bruteforcable-choices") {
|
||||
if len(choices) < 10 && flag.ChoicesCost == 0 {
|
||||
errs = append(errs, fmt.Errorf("requires at least 10 choices to avoid brute-force"))
|
||||
} else if len(choices) < 6 && flag.ChoicesCost > 0 {
|
||||
errs = append(errs, fmt.Errorf("requires at least 10 choices to avoid brute-force"))
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue