Skip to content

Commit

Permalink
Group contents into contentType struct
Browse files Browse the repository at this point in the history
Signed-off-by: Dinesh <dineshudt17@gmail.com>
  • Loading branch information
dineshba authored and svishwanath-tw committed Oct 12, 2019
1 parent ebd4565 commit 98e9b83
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions detector/filecontent_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ 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,
},
}
cc := NewChecksumCompare(additions, ignoreConfig)
re := regexp.MustCompile(`(?i)checksum[ \t]*:[ \t]*[0-9a-fA-F]+`)

Expand All @@ -93,23 +110,13 @@ func (fc *FileContentDetector) Test(additions []gitrepo.Addition, ignoreConfig T
data := []byte(content)
addition.Data = data
}
contents <- content{
name: addition.Name,
path: addition.Path,
contentType: base64Content,
results: fc.detectFile(addition.Data, checkBase64),
}
contents <- content{
name: addition.Name,
path: addition.Path,
contentType: hexContent,
results: fc.detectFile(addition.Data, checkHex),
}
contents <- content{
name: addition.Name,
path: addition.Path,
contentType: creditCardContent,
results: fc.detectFile(addition.Data, checkCreditCardNumber),
for _, ct := range contentTypes {
contents <- content{
name: addition.Name,
path: addition.Path,
contentType: ct.contentType,
results: fc.detectFile(addition.Data, ct.fn),
}
}
}(addition)
}
Expand Down

0 comments on commit 98e9b83

Please sign in to comment.