repochecker/epita: Check full numbered flag has type number
This commit is contained in:
parent
7b2603afb0
commit
79c251d85f
1 changed files with 12 additions and 5 deletions
|
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"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"))
|
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"))
|
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) {
|
func EPITACheckKeyFlagWithChoices(flag *fic.FlagKey, raw string, choices []*fic.FlagChoice, exceptions *sync.CheckExceptions) (errs []error) {
|
||||||
if len(choices) < 10 && flag.ChoicesCost == 0 {
|
if !exceptions.HasException(":bruteforcable-choices") {
|
||||||
errs = append(errs, fmt.Errorf("requires at least 10 choices to avoid brute-force"))
|
if len(choices) < 10 && flag.ChoicesCost == 0 {
|
||||||
} else if len(choices) < 6 && flag.ChoicesCost > 0 {
|
errs = append(errs, fmt.Errorf("requires at least 10 choices to avoid brute-force"))
|
||||||
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
|
return
|
||||||
|
|
|
||||||
Reference in a new issue