Skip to content

Commit

Permalink
Merge f6998f4 into 98e9b83
Browse files Browse the repository at this point in the history
  • Loading branch information
aswinkarthik committed Oct 15, 2019
2 parents 98e9b83 + f6998f4 commit 6ff3c37
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions detector/filecontent_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ func (ct contentType) getMessageFormat() string {
return ""
}

func (ct contentType) getCheckFn() fn {
switch ct {
case base64Content:
return checkBase64
case hexContent:
return checkHex
case creditCardContent:
return checkCreditCardNumber
}
return nil
}

type content struct {
name gitrepo.FileName
path gitrepo.FilePath
Expand All @@ -72,22 +84,10 @@ type content struct {
}

func (fc *FileContentDetector) Test(additions []gitrepo.Addition, ignoreConfig TalismanRCIgnore, result *DetectionResults) {
contentTypes := []struct {
contentType
fn
}{
{
contentType: base64Content,
fn: checkBase64,
},
{
contentType: hexContent,
fn: checkHex,
},
{
contentType: creditCardContent,
fn: checkCreditCardNumber,
},
contentTypes := []contentType{
base64Content,
hexContent,
creditCardContent,
}
cc := NewChecksumCompare(additions, ignoreConfig)
re := regexp.MustCompile(`(?i)checksum[ \t]*:[ \t]*[0-9a-fA-F]+`)
Expand All @@ -114,8 +114,8 @@ func (fc *FileContentDetector) Test(additions []gitrepo.Addition, ignoreConfig T
contents <- content{
name: addition.Name,
path: addition.Path,
contentType: ct.contentType,
results: fc.detectFile(addition.Data, ct.fn),
contentType: ct,
results: fc.detectFile(addition.Data, ct.getCheckFn()),
}
}
}(addition)
Expand Down

0 comments on commit 6ff3c37

Please sign in to comment.