You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ly...@apache.org on 2024/02/28 10:41:41 UTC

(incubator-devlake) branch release-v0.21 updated: fix(security): fix cwe-276, (parts of)cwe-22 (#7045) (#7047)

This is an automated email from the ASF dual-hosted git repository.

lynwee pushed a commit to branch release-v0.21
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/release-v0.21 by this push:
     new e8727aad9 fix(security): fix cwe-276, (parts of)cwe-22 (#7045) (#7047)
e8727aad9 is described below

commit e8727aad98c5994b72b946564052066368ff510a
Author: github-actions[bot] <41...@users.noreply.github.com>
AuthorDate: Wed Feb 28 18:41:35 2024 +0800

    fix(security): fix cwe-276, (parts of)cwe-22 (#7045) (#7047)
    
    * fix(security): fix cwe-276, (parts of)cwe-22
    
    * fix(test): fix errors
    
    * fix(test): fix errors
    
    * fix(test): fix errors
    
    Co-authored-by: Lynwee <li...@merico.dev>
---
 backend/impls/logruslog/stream.go |  2 +-
 backend/test/helper/utils.go      | 22 +++++++---------------
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/backend/impls/logruslog/stream.go b/backend/impls/logruslog/stream.go
index d5429e19b..aa6770f24 100644
--- a/backend/impls/logruslog/stream.go
+++ b/backend/impls/logruslog/stream.go
@@ -32,7 +32,7 @@ func GetFileStream(path string) (io.Writer, errors.Error) {
 	if err != nil {
 		return nil, errors.Convert(err)
 	}
-	file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777)
+	file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
 	if err != nil {
 		return nil, errors.Convert(err)
 	}
diff --git a/backend/test/helper/utils.go b/backend/test/helper/utils.go
index 7bf603642..f1e228825 100644
--- a/backend/test/helper/utils.go
+++ b/backend/test/helper/utils.go
@@ -31,10 +31,16 @@ import (
 
 // IsWSL FIXME
 func IsWSL() bool {
-	lines, err := readFile("/proc/version")
+	file, err := os.Open("/proc/version")
 	if err != nil {
 		return false
 	}
+	defer file.Close()
+	var lines []string
+	scanner := bufio.NewScanner(file)
+	for scanner.Scan() {
+		lines = append(lines, scanner.Text())
+	}
 	for _, line := range lines {
 		l := strings.ToLower(line)
 		if strings.Contains(l, "microsoft") {
@@ -85,17 +91,3 @@ func Contains[T any](list []T, elem any) bool {
 	}
 	return false
 }
-
-func readFile(path string) ([]string, error) {
-	file, err := os.Open(path)
-	if err != nil {
-		return nil, err
-	}
-	defer file.Close()
-	var lines []string
-	scanner := bufio.NewScanner(file)
-	for scanner.Scan() {
-		lines = append(lines, scanner.Text())
-	}
-	return lines, scanner.Err()
-}