diff options
author | 2022-02-14 08:24:21 -0800 | |
---|---|---|
committer | 2022-02-14 11:24:21 -0500 | |
commit | c6709d930f71d64dc3b5d1a15943e5c927e808cc (patch) | |
tree | 2816c901cdfcc3818c43a3bc972e5804a90ca34a /plugin/dnssec/dnskey.go | |
parent | b40f2a0a44316ed91bbc5f42fe03819c0f1f98a7 (diff) | |
download | coredns-c6709d930f71d64dc3b5d1a15943e5c927e808cc.tar.gz coredns-c6709d930f71d64dc3b5d1a15943e5c927e808cc.tar.zst coredns-c6709d930f71d64dc3b5d1a15943e5c927e808cc.zip |
Fix security scans by cleaning up file path (#5185)
While performing security scans there were several
issue raised as G304 (CWE-22): Potential file inclusion via variable.
As some files path are taken from user input, it is possible the
filepath passed by user may have unintended effect if not properly formed.
This fix add Clean to remove the security warning and address some
potential issue.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'plugin/dnssec/dnskey.go')
-rw-r--r-- | plugin/dnssec/dnskey.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/plugin/dnssec/dnskey.go b/plugin/dnssec/dnskey.go index 11e18fdc6..161db9471 100644 --- a/plugin/dnssec/dnskey.go +++ b/plugin/dnssec/dnskey.go @@ -6,6 +6,7 @@ import ( "crypto/rsa" "errors" "os" + "path/filepath" "time" "github.com/coredns/coredns/request" @@ -25,7 +26,7 @@ type DNSKEY struct { // ParseKeyFile read a DNSSEC keyfile as generated by dnssec-keygen or other // utilities. It adds ".key" for the public key and ".private" for the private key. func ParseKeyFile(pubFile, privFile string) (*DNSKEY, error) { - f, e := os.Open(pubFile) + f, e := os.Open(filepath.Clean(pubFile)) if e != nil { return nil, e } @@ -35,7 +36,7 @@ func ParseKeyFile(pubFile, privFile string) (*DNSKEY, error) { return nil, e } - f, e = os.Open(privFile) + f, e = os.Open(filepath.Clean(privFile)) if e != nil { return nil, e } |