-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #353 from kubescape/feature/network-anomaly
Feature/network anomaly
- Loading branch information
Showing
11 changed files
with
402 additions
and
19 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package dnscache | ||
|
||
import ( | ||
"github.com/kubescape/go-logger" | ||
"github.com/kubescape/node-agent/pkg/dnsmanager" | ||
"github.com/kubescape/node-agent/pkg/objectcache" | ||
) | ||
|
||
var _ objectcache.DnsCache = (*DnsCacheImpl)(nil) | ||
|
||
type DnsCacheImpl struct { | ||
dnsResolver dnsmanager.DNSResolver | ||
} | ||
|
||
func NewDnsCache(dnsResolver dnsmanager.DNSResolver) *DnsCacheImpl { | ||
return &DnsCacheImpl{ | ||
dnsResolver: dnsResolver, | ||
} | ||
} | ||
|
||
func (d *DnsCacheImpl) ResolveIpToDomain(ip string) string { | ||
if d.dnsResolver == nil { | ||
logger.L().Debug("DNS resolver is not set") | ||
return "" | ||
} | ||
|
||
domain, ok := d.dnsResolver.ResolveIPAddress(ip) | ||
if !ok { | ||
return "" | ||
} | ||
|
||
return domain | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package objectcache | ||
|
||
type DnsCache interface { | ||
ResolveIpToDomain(ip string) string | ||
} | ||
|
||
var _DnsCache = (*DnsCacheMock)(nil) | ||
|
||
type DnsCacheMock struct { | ||
} | ||
|
||
func (dc *DnsCacheMock) ResolveIpToDomain(_ string) string { | ||
return "" | ||
} |
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
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
Oops, something went wrong.