forked from gane5hvarma/panther
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
username
and email
indicators to pantherlog
(#2117)
* Add email scanner and indicator * Add usename indicator and scanner * Add tests for indicator scanners * mage gen fmt Co-authored-by: panther-bot <[email protected]>
- Loading branch information
1 parent
4c39080
commit 8624f93
Showing
3 changed files
with
116 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
package pantherlog | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
/** | ||
* Panther is a Cloud-Native SIEM for the Modern Security Team. | ||
* Copyright (C) 2020 Panther Labs Inc | ||
|
@@ -17,3 +23,85 @@ package pantherlog | |
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
func TestScanIPAddress(t *testing.T) { | ||
assert := require.New(t) | ||
w := &ValueBuffer{} | ||
|
||
ScanIPAddress(w, "foo") | ||
assert.True(w.IsEmpty()) | ||
ScanIPAddress(w, "") | ||
assert.True(w.IsEmpty()) | ||
ScanIPAddress(w, " ") | ||
assert.True(w.IsEmpty()) | ||
ScanIPAddress(w, "[email protected]") | ||
assert.True(w.IsEmpty()) | ||
ScanIPAddress(w, "23.23.23.23") | ||
assert.False(w.IsEmpty()) | ||
assert.Equal([]string{"23.23.23.23"}, w.Get(FieldIPAddress)) | ||
} | ||
|
||
func TestScanHostname(t *testing.T) { | ||
assert := require.New(t) | ||
w := &ValueBuffer{} | ||
|
||
ScanHostname(w, "") | ||
assert.True(w.IsEmpty()) | ||
ScanHostname(w, " ") | ||
assert.True(w.IsEmpty()) | ||
ScanHostname(w, "23.23.23.23") | ||
assert.False(w.IsEmpty()) | ||
assert.Equal([]string{"23.23.23.23"}, w.Get(FieldIPAddress)) | ||
w.Reset() | ||
ScanHostname(w, "foo ") | ||
assert.False(w.IsEmpty()) | ||
assert.Equal([]string{"foo"}, w.Get(FieldDomainName)) | ||
} | ||
|
||
func TestScanURL(t *testing.T) { | ||
assert := require.New(t) | ||
w := &ValueBuffer{} | ||
ScanURL(w, "") | ||
assert.True(w.IsEmpty()) | ||
ScanURL(w, " ") | ||
assert.True(w.IsEmpty()) | ||
ScanURL(w, "23.23.23.23") | ||
assert.True(w.IsEmpty()) | ||
ScanURL(w, "http://23.23.23.23/foo") | ||
assert.Equal([]string{"23.23.23.23"}, w.Get(FieldIPAddress)) | ||
w.Reset() | ||
ScanURL(w, "foo ") | ||
assert.True(w.IsEmpty()) | ||
ScanURL(w, "http://foo") | ||
assert.False(w.IsEmpty()) | ||
assert.Equal([]string{"foo"}, w.Get(FieldDomainName)) | ||
} | ||
|
||
func TestScanEmail(t *testing.T) { | ||
assert := require.New(t) | ||
w := &ValueBuffer{} | ||
ScanEmail(w, "foo") | ||
assert.True(w.IsEmpty()) | ||
ScanEmail(w, "") | ||
assert.True(w.IsEmpty()) | ||
ScanEmail(w, " ") | ||
assert.True(w.IsEmpty()) | ||
ScanEmail(w, "23.23.23.23") | ||
assert.True(w.IsEmpty()) | ||
ScanEmail(w, "[email protected]") | ||
assert.False(w.IsEmpty()) | ||
ScanEmail(w, "[email protected] ") | ||
assert.Equal([]string{"[email protected]"}, w.Get(FieldEmail)) | ||
} | ||
|
||
func TestScanDomain(t *testing.T) { | ||
assert := require.New(t) | ||
w := &ValueBuffer{} | ||
FieldDomainName.ScanValues(w, "") | ||
assert.True(w.IsEmpty()) | ||
FieldDomainName.ScanValues(w, " ") | ||
assert.True(w.IsEmpty()) | ||
FieldDomainName.ScanValues(w, "foo ") | ||
assert.False(w.IsEmpty()) | ||
assert.Equal([]string{"foo"}, w.Get(FieldDomainName)) | ||
} |