feat(scan): диапазон IPv4-подсетей CIDR–CIDR в поле целей (нормализация в список)
Made-with: Cursor
This commit is contained in:
@@ -121,7 +121,7 @@ func NewMemoryStore() *MemoryStore {
|
||||
}
|
||||
|
||||
func (s *MemoryStore) CreateScan(req CreateScanRequest) (ScanJob, error) {
|
||||
if err := validateCreateScanRequest(req); err != nil {
|
||||
if err := validateCreateScanRequest(&req); err != nil {
|
||||
return ScanJob{}, err
|
||||
}
|
||||
|
||||
@@ -340,16 +340,16 @@ func applyDefaultOptions(opts *ScanOptions) {
|
||||
}
|
||||
}
|
||||
|
||||
func validateCreateScanRequest(req CreateScanRequest) error {
|
||||
func validateCreateScanRequest(req *CreateScanRequest) error {
|
||||
if len(req.CIDRs) == 0 {
|
||||
return errors.New("cidrs must not be empty")
|
||||
}
|
||||
|
||||
for _, cidr := range req.CIDRs {
|
||||
if _, _, err := net.ParseCIDR(cidr); err != nil {
|
||||
return errors.New("invalid cidr: " + cidr)
|
||||
}
|
||||
expanded, err := expandCIDRSFromRequest(req.CIDRs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req.CIDRs = expanded
|
||||
|
||||
for _, ip := range req.ExcludeIPs {
|
||||
if net.ParseIP(ip) == nil {
|
||||
|
||||
Reference in New Issue
Block a user