fix(contrib/fvuls): Add flag to specify snmp community for future-vuls discover (#1762)
* add: community option for discover command * fix: README --------- Co-authored-by: 和田皓翔 <wadahiroka@192.168.0.6>
This commit is contained in:
@@ -5,6 +5,7 @@ const (
|
||||
DiscoverTomlFileName = "discover_list.toml"
|
||||
SnmpVersion = "v2c"
|
||||
FvulsDomain = "vuls.biz"
|
||||
Community = "public"
|
||||
DiscoverTomlTimeStampFormat = "20060102150405"
|
||||
)
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
// ActiveHosts ...
|
||||
func ActiveHosts(cidr string, outputFile string, snmpVersion string) error {
|
||||
func ActiveHosts(cidr string, outputFile string, snmpVersion string, community string) error {
|
||||
scanner := pingscanner.PingScanner{
|
||||
CIDR: cidr,
|
||||
PingOptions: []string{
|
||||
@@ -42,7 +42,7 @@ func ActiveHosts(cidr string, outputFile string, snmpVersion string) error {
|
||||
|
||||
servers := make(config.DiscoverToml)
|
||||
for _, activeHost := range activeHosts {
|
||||
cpes, err := executeSnmp2cpe(activeHost, snmpVersion)
|
||||
cpes, err := executeSnmp2cpe(activeHost, snmpVersion, community)
|
||||
if err != nil {
|
||||
fmt.Printf("failed to execute snmp2cpe. err: %v\n", err)
|
||||
continue
|
||||
@@ -100,9 +100,9 @@ func ActiveHosts(cidr string, outputFile string, snmpVersion string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func executeSnmp2cpe(addr string, snmpVersion string) (cpes map[string][]string, err error) {
|
||||
func executeSnmp2cpe(addr string, snmpVersion string, community string) (cpes map[string][]string, err error) {
|
||||
fmt.Printf("%s: Execute snmp2cpe...\n", addr)
|
||||
result, err := exec.Command("./snmp2cpe", snmpVersion, addr, "public").CombinedOutput()
|
||||
result, err := exec.Command("./snmp2cpe", snmpVersion, addr, community).CombinedOutput()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to execute snmp2cpe. err: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user