FEATURE: Search screened IP address in blocks (#15461)

An admin could search for all screened ip addresses in a block by
using wildcards. 192.168.* returned all IPs in range 192.168.0.0/16.
This feature allows admins to search for a single IP address in all
screened IP blocks. 192.168.0.1 returns all IP blocks that match it,
for example 192.168.0.0/16.

* FEATURE: Remove roll up button for screened IPs

* FIX: Match more specific screened IP address first
This commit is contained in:
Bianca Nenciu
2022-01-11 09:16:51 +02:00
committed by GitHub
parent 5a8b8f6f1e
commit 5d35c38db2
9 changed files with 29 additions and 99 deletions

View File

@ -1,5 +1,7 @@
# frozen_string_literal: true
require_dependency 'ip_addr'
class Admin::ScreenedIpAddressesController < Admin::AdminController
before_action :fetch_screened_ip_address, only: [:update, :destroy]
@ -9,7 +11,7 @@ class Admin::ScreenedIpAddressesController < Admin::AdminController
filter = IPAddr.handle_wildcards(filter)
screened_ip_addresses = ScreenedIpAddress
screened_ip_addresses = screened_ip_addresses.where("cidr :filter >>= ip_address", filter: filter) if filter.present?
screened_ip_addresses = screened_ip_addresses.where("cidr :filter >>= ip_address OR ip_address >>= cidr :filter", filter: filter) if filter.present?
screened_ip_addresses = screened_ip_addresses.limit(200).order('match_count desc')
begin
@ -44,11 +46,6 @@ class Admin::ScreenedIpAddressesController < Admin::AdminController
render json: success_json
end
def roll_up
subnets = ScreenedIpAddress.roll_up(current_user)
render json: success_json.merge!(subnets: subnets)
end
private
def allowed_params