From c6709d930f71d64dc3b5d1a15943e5c927e808cc Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Mon, 14 Feb 2022 08:24:21 -0800 Subject: 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 --- plugin/file/setup.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugin/file/setup.go') diff --git a/plugin/file/setup.go b/plugin/file/setup.go index c9b8ddf3e..b8985f2d2 100644 --- a/plugin/file/setup.go +++ b/plugin/file/setup.go @@ -88,7 +88,7 @@ func fileParse(c *caddy.Controller) (Zones, error) { fileName = filepath.Join(config.Root, fileName) } - reader, err := os.Open(fileName) + reader, err := os.Open(filepath.Clean(fileName)) if err != nil { openErr = err } -- cgit v1.2.3