Skip to content

Commit

Permalink
Support settings apkIndexArchiveURL via env FANAL_APK_INDEX_ARCHIVE_U…
Browse files Browse the repository at this point in the history
  • Loading branch information
mozillazg authored Apr 13, 2020
1 parent cfec7a7 commit 0b612e5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions analyzer/command/apk/apk.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log"
"net/http"
builtinos "os"
"sort"
"strings"
"time"
Expand All @@ -19,7 +20,13 @@ import (
"github.com/aquasecurity/fanal/types"
)

const envApkIndexArchiveURL = "FANAL_APK_INDEX_ARCHIVE_URL"
var apkIndexArchiveURL = "https://raw.githubusercontent.com/knqyf263/apkIndex-archive/master/alpine/v%s/main/x86_64/history.json"

func init() {
if builtinos.Getenv(envApkIndexArchiveURL) != "" {
apkIndexArchiveURL = builtinos.Getenv(envApkIndexArchiveURL)
}
analyzer.RegisterCommandAnalyzer(&alpineCmdAnalyzer{})
}

Expand Down Expand Up @@ -49,10 +56,6 @@ type pkg struct {

type version map[string]int

const (
apkIndexArchiveURL = "https://raw.githubusercontent.com/knqyf263/apkIndex-archive/master/alpine/v%s/main/x86_64/history.json"
)

func (a alpineCmdAnalyzer) Analyze(targetOS types.OS, fileMap extractor.FileMap) (pkgs []types.Package, err error) {
if targetOS.Family != os.Alpine {
return nil, xerrors.New("not target")
Expand Down

0 comments on commit 0b612e5

Please sign in to comment.