@@ -61,7 +61,11 @@ func main() {
6161 contractOutputPath := flag .Arg (1 )
6262 commandOutputPath := flag .Arg (2 )
6363
64- abiFile , err := ioutil .ReadFile (abiPath ) // #nosec
64+ // #nosec G304 (file path provided as taint input)
65+ // This line is placed in the auxiliary generator code,
66+ // not in the core application. User input has to be passed to
67+ // provide a path to the contract ABI.
68+ abiFile , err := ioutil .ReadFile (abiPath )
6569 if err != nil {
6670 panic (fmt .Sprintf (
6771 "Failed to read ABI file at [%v]: [%v]." ,
@@ -223,7 +227,13 @@ func organizeImports(outFile string, buf *bytes.Buffer) error {
223227// Stores the Buffer `buf` content to a file in `filePath`
224228func saveBufferToFile (buf * bytes.Buffer , filePath string ) error {
225229 file , err := os .Create (filePath )
226- defer file .Close () // #nosec
230+
231+ // #nosec G104 (audit errors not checked)
232+ // This line is placed in the auxiliary generator code,
233+ // not in the core application. Also, the Close function returns only
234+ // the error. It doesn't return any other values which can be a security
235+ // threat when used without checking the error.
236+ defer file .Close ()
227237 if err != nil {
228238 return fmt .Errorf ("output file %s creation failed [%v]" , filePath , err )
229239 }
0 commit comments