Skip to content

Commit

Permalink
Merge pull request #3452 from mercedes-benz/feature-3447-windows-Clie…
Browse files Browse the repository at this point in the history
…nt-ignoring-exclude-patterns

fixed windows client exclude handling #3447
  • Loading branch information
sven-dmlr authored Sep 25, 2024
2 parents 9edeb79 + d055f25 commit e62bcb0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sechub-cli/src/mercedes-benz.com/sechub/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ func validateTempDir(config *Config) bool {
func validateOutputLocation(config *Config) bool {
if config.outputLocation == "" || config.outputLocation == "." {
config.outputFolder = "."
} else if !strings.Contains(config.outputLocation, "/") && !strings.Contains(config.outputLocation, string(os.PathSeparator)) {
} else if !strings.Contains(config.outputLocation, "/") && !strings.Contains(config.outputLocation, PathSeparator) {
// Only a name is provided - can be an output file name or a directory
if sechubUtil.VerifyDirectoryExists(config.outputLocation) {
config.outputFolder, _ = filepath.Abs(config.outputLocation)
Expand Down
12 changes: 11 additions & 1 deletion sechub-cli/src/mercedes-benz.com/sechub/cli/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

package cli

import "time"
import (
"os"
"time"
)

// CurrentAPIVersion - SecHub current api version
const CurrentAPIVersion = "1.0"
Expand Down Expand Up @@ -316,3 +319,10 @@ const MaximumNumberOfCMDLineArguments = 50

// HTTPRetries - maximum number of retries for HTTP calls
const HTTPMaxRetries = 60

/* ---------------------------------- */
/* -------- OS specific ------------- */
/* ---------------------------------- */

// OS's path separator as string (Unix-like: "/", Windows: "\")
const PathSeparator = string(os.PathSeparator)
10 changes: 7 additions & 3 deletions sechub-cli/src/mercedes-benz.com/sechub/util/filepathmatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,26 @@
package util

import (
"os"
"path/filepath"
"strings"

"github.com/bmatcuk/doublestar/v4"
)

// OS's path separator as string (Unix-like: "/", Windows: "\")
const PathSeparator = string(os.PathSeparator)

// FilePathMatch - This method provides ANT like selectors.
// See https://ant.apache.org/manual/dirtasks.html
// For example: "**/a*.txt" will accept
// - "/home/tester/xyz/a1234.txt"
// - "a1b.txt"
//
func FilePathMatch(path string, pattern string) (result bool) {
// Make simple patterns like `*.java` also work
if !strings.Contains(pattern, "/") {
pattern = "**/" + pattern
// Make simple patterns like `*.java` also work with doublestar.PathMatch()
if !strings.Contains(pattern, PathSeparator) {
pattern = "**" + PathSeparator + pattern
}

match, _ := doublestar.PathMatch(pattern, path)
Expand Down

0 comments on commit e62bcb0

Please sign in to comment.