@@ -17,6 +17,7 @@ package cmd
1717
1818import (
1919 "log"
20+ "strconv"
2021 "strings"
2122
2223 "github.com/fuzzitdev/fuzzit/v2/client"
@@ -28,6 +29,20 @@ import (
2829
2930var newJob = client.Job {}
3031
32+ var allowedCPUs = map [string ]bool {
33+ "0.1" : true ,
34+ "0.2" : true ,
35+ "0.3" : true ,
36+ "0.4" : true ,
37+ "0.5" : true ,
38+ "0.6" : true ,
39+ "0.7" : true ,
40+ "0.8" : true ,
41+ "0.9" : true ,
42+ "1" : true ,
43+ "1.0" : true ,
44+ }
45+
3146var jobCmd = & cobra.Command {
3247 Use : "job [target_id] [files...]" ,
3348 Short : "create new fuzzing job" ,
@@ -41,6 +56,22 @@ var jobCmd = &cobra.Command{
4156 log .Fatalf ("--engine should be either libfuzzer or jqf. Received: %s" , newJob .Type )
4257 }
4358
59+ if ! allowedCPUs [newJob .CPUs ] {
60+ log .Fatalf ("got %s cpus. CPUs can only be one of 0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.0\n " , newJob .CPUs )
61+ }
62+
63+ if ! strings .HasSuffix (newJob .Memory , "Mi" ) {
64+ log .Fatalf ("got %s memory. Memory should be suffixed by Mi\n " , newJob .Memory )
65+ }
66+ megabytes := newJob .Memory [:len (newJob .Memory )- 2 ]
67+ i , err := strconv .Atoi (megabytes )
68+ if err != nil {
69+ log .Fatalln (err )
70+ }
71+ if i > 2048 {
72+ log .Fatalf ("got %d Mi memory. > 2048Mi memory is only supported for enterprise customers\n " , i )
73+ }
74+
4475 image := client .HostToDocker [newJob .Host ]
4576 if image == "" {
4677 if newJob .Host == "" {
@@ -108,7 +139,10 @@ func init() {
108139
109140 jobCmd .Flags ().StringVar (& newJob .Type , "type" , "fuzzing" , "fuzzing/regression/local-regression" )
110141 jobCmd .Flags ().StringVar (& newJob .Engine , "engine" , "libfuzzer" , "libfuzzer/jqf" )
111- jobCmd .Flags ().Uint16Var (& newJob .Parallelism , "cpus" , 1 , "number of cpus to use (only relevant for fuzzing job)" )
142+ jobCmd .Flags ().StringVar (& newJob .CPUs , "cpus" , "1" , "number of cpus to use (only relevant for fuzzing job)" )
143+ jobCmd .Flags ().StringVar (& newJob .Memory , "memory" , "2048Mi" , "number of cpus to use (only relevant for fuzzing job)" )
144+ jobCmd .Flags ().MarkHidden ("memory" )
145+ jobCmd .Flags ().MarkHidden ("cpus" )
112146 jobCmd .Flags ().StringVar (& newJob .Revision , "revision" , revision , "Revision tag of fuzzer (populates automatically from git,travis,circleci)" )
113147 jobCmd .Flags ().StringVar (& newJob .Branch , "branch" , branch , "Branch of the fuzzer (populates automatically from git,travis,circleci)" )
114148 jobCmd .Flags ().StringVar (& newJob .Host , "host" , "" , "docker image to use when running the fuzzer. Options: stretch-llvm8/stretch-llvm9/bionic-swift51" )
0 commit comments