diff options
| -rw-r--r-- | .github/workflows/docker.yml | 4 | ||||
| -rw-r--r-- | main.go | 11 |
2 files changed, 7 insertions, 8 deletions
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index b44e0b7..e9d4460 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml | |||
| @@ -21,10 +21,10 @@ jobs: | |||
| 21 | uses: actions/checkout@v3 | 21 | uses: actions/checkout@v3 |
| 22 | 22 | ||
| 23 | - name: Setup docker | 23 | - name: Setup docker |
| 24 | uses: docker/setup-buildx-action@v1 | 24 | uses: docker/setup-buildx-action@v2 |
| 25 | 25 | ||
| 26 | - name: Log into container registry | 26 | - name: Log into container registry |
| 27 | uses: docker/login-action@v1 | 27 | uses: docker/login-action@v2 |
| 28 | with: | 28 | with: |
| 29 | registry: ghcr.io | 29 | registry: ghcr.io |
| 30 | username: ${{ github.repository_owner }} | 30 | username: ${{ github.repository_owner }} |
| @@ -6,7 +6,6 @@ import ( | |||
| 6 | "fmt" | 6 | "fmt" |
| 7 | "io" | 7 | "io" |
| 8 | "io/fs" | 8 | "io/fs" |
| 9 | "io/ioutil" | ||
| 10 | "log" | 9 | "log" |
| 11 | "net/http" | 10 | "net/http" |
| 12 | "os" | 11 | "os" |
| @@ -103,7 +102,7 @@ func handleError(err error, desc string, isFatal bool) { | |||
| 103 | // returns its location. | 102 | // returns its location. |
| 104 | func writeRulesFiles(content fs.FS) string { | 103 | func writeRulesFiles(content fs.FS) string { |
| 105 | // create temporary folder structure | 104 | // create temporary folder structure |
| 106 | rulesPath, err := ioutil.TempDir(os.TempDir(), TempDirPrefix) | 105 | rulesPath, err := os.MkdirTemp(os.TempDir(), TempDirPrefix) |
| 107 | handleError(err, "unable to create temporary folder", true) | 106 | handleError(err, "unable to create temporary folder", true) |
| 108 | err = os.Mkdir(path.Join(rulesPath, "whitelists"), 0755) | 107 | err = os.Mkdir(path.Join(rulesPath, "whitelists"), 0755) |
| 109 | handleError(err, "unable to create temporary subfolder", true) | 108 | handleError(err, "unable to create temporary subfolder", true) |
| @@ -113,7 +112,7 @@ func writeRulesFiles(content fs.FS) string { | |||
| 113 | // read embedded content | 112 | // read embedded content |
| 114 | f, err := content.Open(path.Join("data", rulesFile)) | 113 | f, err := content.Open(path.Join("data", rulesFile)) |
| 115 | handleError(err, "unable to read embedded rule", true) | 114 | handleError(err, "unable to read embedded rule", true) |
| 116 | ruleData, err := ioutil.ReadAll(f) | 115 | ruleData, err := io.ReadAll(f) |
| 117 | 116 | ||
| 118 | // write to temporary file | 117 | // write to temporary file |
| 119 | err = os.WriteFile(path.Join(rulesPath, rulesFile), ruleData, 0640) | 118 | err = os.WriteFile(path.Join(rulesPath, rulesFile), ruleData, 0640) |
| @@ -141,12 +140,12 @@ func updateRules() { | |||
| 141 | err := resp.Body.Close() | 140 | err := resp.Body.Close() |
| 142 | handleError(err, "unable to close response body", false) | 141 | handleError(err, "unable to close response body", false) |
| 143 | }() | 142 | }() |
| 144 | data, err := ioutil.ReadAll(resp.Body) | 143 | data, err := io.ReadAll(resp.Body) |
| 145 | handleError(err, "unable to read response body", false) | 144 | handleError(err, "unable to read response body", false) |
| 146 | return data | 145 | return data |
| 147 | } | 146 | } |
| 148 | writeFile := func(dst string, data []byte) { | 147 | writeFile := func(dst string, data []byte) { |
| 149 | err := ioutil.WriteFile(dst, data, 0640) | 148 | err := os.WriteFile(dst, data, 0640) |
| 150 | handleError(err, "unable to write downloaded file", true) | 149 | handleError(err, "unable to write downloaded file", true) |
| 151 | } | 150 | } |
| 152 | 151 | ||
| @@ -276,7 +275,7 @@ func loadRulesFile(fileName string) (*yara.Rules, error) { | |||
| 276 | } | 275 | } |
| 277 | 276 | ||
| 278 | // read file content | 277 | // read file content |
| 279 | data, err := ioutil.ReadFile(ruleName) | 278 | data, err := os.ReadFile(ruleName) |
| 280 | if err != nil { | 279 | if err != nil { |
| 281 | return nil, fmt.Errorf("unable to read rules file: %v", err) | 280 | return nil, fmt.Errorf("unable to read rules file: %v", err) |
| 282 | } | 281 | } |
