Skip to content

Commit

Permalink
Update staticcheck and fulfill requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
elivlo committed Apr 13, 2023
1 parent 438ac6a commit a96b94e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
run: goveralls -coverprofile=c.out -service=github

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@v0.3.0
run: go install honnef.co/go/tools/cmd/staticcheck@v0.4.3

- name: Run staticcheck for possible optimizations
run: staticcheck -tests=false
3 changes: 1 addition & 2 deletions nmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"encoding/xml"
"fmt"
"io"
"io/ioutil"
"os/exec"
"strings"
"syscall"
Expand Down Expand Up @@ -135,7 +134,7 @@ func (s *Scanner) Run() (result *Run, warnings *[]string, err error) {
return err
})
} else {
go io.Copy(ioutil.Discard, stdoutDuplicate)
go io.Copy(io.Discard, stdoutDuplicate)
}

// Run nmap process.
Expand Down
12 changes: 10 additions & 2 deletions xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/xml"
"io"
"io/ioutil"
"os"
"strconv"
"time"

Expand Down Expand Up @@ -40,7 +40,15 @@ type Run struct {

// ToFile writes a Run as XML into the specified file path.
func (r Run) ToFile(filePath string) error {
return ioutil.WriteFile(filePath, r.rawXML, 0666)
file, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
return err
}
_, err = file.Write(r.rawXML)
if err != nil {
return err
}
return err
}

// ToReader writes the raw XML into an streamable buffer.
Expand Down

0 comments on commit a96b94e

Please sign in to comment.