Skip to content

Commit

Permalink
Removed remaining trailing whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
hknutzen committed Mar 15, 2017
1 parent 24f540f commit 360eed0
Show file tree
Hide file tree
Showing 6 changed files with 493 additions and 493 deletions.
112 changes: 56 additions & 56 deletions bin/export-netspoc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ sub ip_nat_for_object {
else {

# Dynamic NAT, take whole network.
join('/',
join('/',
print_ip($network->{ip}), print_ip($network->{mask}));
}
}
Expand Down Expand Up @@ -184,9 +184,9 @@ sub ip_nat_for_object {
'hidden';
}
else {

# Dynamic NAT, take whole network.
join('/',
join('/',
print_ip($network->{ip}), print_ip($network->{mask}));
}
}
Expand All @@ -196,7 +196,7 @@ sub ip_nat_for_object {
elsif ($obj->{ip} eq 'negotiated') {

# Take whole network.
join('/',
join('/',
print_ip($network->{ip}), print_ip($network->{mask}));
}
else {
Expand Down Expand Up @@ -248,31 +248,31 @@ sub adapt_owner_names {
}
}

sub owner_for_object {
sub owner_for_object {
my ($object) = @_;
if (my $owner_obj = $object->{owner}) {
return $owner_obj->{name};
}
return ();
}

sub part_owners_for_object {
sub part_owners_for_object {
my ($object) = @_;
if (my $aref = $object->{part_owners}) {
return map { $_->{name} } @$aref;
}
return ();
}

sub outer_owners_for_object {
sub outer_owners_for_object {
my ($object) = @_;
if (my $list = $object->{outer_owners}) {
return map { $_->{name} } @$list;
}
return ();
}

sub owners_for_objects {
sub owners_for_objects {
my ($objects) = @_;
my %owners;
for my $object (@$objects) {
Expand All @@ -283,7 +283,7 @@ sub owners_for_objects {
return [ sort values %owners ];
}

sub part_owners_for_objects {
sub part_owners_for_objects {
my ($objects) = @_;
my %owners;
for my $object (@$objects) {
Expand All @@ -294,7 +294,7 @@ sub part_owners_for_objects {
return [ sort values %owners ];
}

sub outer_owners_for_objects {
sub outer_owners_for_objects {
my ($objects) = @_;
my %owners;
for my $object (@$objects) {
Expand Down Expand Up @@ -359,12 +359,12 @@ sub proto_descr {
$num ||= 0;
push @result, [ $desc, $ptype, $num ];
}
@result =
@result =
map { $_->[0] }

# Sort by protocol, port/type, all (if proto and num are equal)
sort { $a->[1] cmp $b->[1] ||
$a->[2] <=> $b->[2] ||
sort { $a->[1] cmp $b->[1] ||
$a->[2] <=> $b->[2] ||
$a->[0] cmp $b->[0] }
@result;
return \@result;
Expand All @@ -377,7 +377,7 @@ sub find_visibility {
my @extra_uowners = grep { not $hash{$_} } @$uowners;
my @DA_extra = grep({ $_ =~ /^DA_/ } @extra_uowners);
my @other_extra = grep({ $_ !~ /^DA_/ } @extra_uowners);

# No known owner or owner of users.
if (not @$owners and not @$uowners) {
# Default: private
Expand All @@ -404,7 +404,7 @@ my %all_objects;
# Split service, if 'user' has different values in normalized rules.
sub normalize_services_for_export {
progress("Normalize services for export");
my @result;
my @result;
for my $service (sort by_name values %services) {
next if $service->{disabled};
my $sname = $service->{name};
Expand All @@ -424,12 +424,12 @@ sub normalize_services_for_export {

for my $unexpanded (@$rules) {
my $action = $unexpanded->{action};
my $prt_list = proto_descr(expand_protocols($unexpanded->{prt},
my $prt_list = proto_descr(expand_protocols($unexpanded->{prt},
"rule in $context"));
my $has_user = $unexpanded->{has_user};

for my $element ($foreach ? @$user : ($user)) {
my $src_dst_list_pairs =
my $src_dst_list_pairs =
normalize_src_dst_list($unexpanded, $element, $context);
for my $src_dst_list (@$src_dst_list_pairs) {
my ($src_list, $dst_list) = @$src_dst_list;
Expand All @@ -438,7 +438,7 @@ sub normalize_services_for_export {
# for case like
# src = user; dst = any:[user];
if ($has_user eq 'both' and
not aref_eq($src_list, $dst_list))
not aref_eq($src_list, $dst_list))
{
if ($seen_as_user->($src_list)) {
$has_user = 'src';
Expand All @@ -449,7 +449,7 @@ sub normalize_services_for_export {
elsif(@$src_list >= @$dst_list) {
$has_user = 'src';
}
else {
else {
$has_user = 'dst';
}
}
Expand Down Expand Up @@ -482,19 +482,19 @@ sub normalize_services_for_export {
my $rules = $key2rules{$user_key};
my $new_service = { %$service,
user => $user_list,
rules => $rules,
rules => $rules,
};
$new_service->{is_split} = 1 if $is_split;
push @result, $new_service;
}
}
return \@result;
}

sub setup_service_info {
my ($normalized_services) = @_;
progress("Setup service info");

for my $service (@$normalized_services) {
my $users = $service->{user};

Expand Down Expand Up @@ -529,7 +529,7 @@ sub setup_service_info {
@all_objects{@objects, @$users} = (@objects, @$users);

# Input: owner objects, output: owner names
my $owners = owners_for_objects(\@objects);
my $owners = owners_for_objects(\@objects);
if ($service->{sub_owner}) {
$service->{sub_owner} = $service->{sub_owner}->{name};
}
Expand Down Expand Up @@ -590,13 +590,13 @@ sub setup_part_owners {
# debug "$obj->{name} : $owner->{name}";
}
}
};
};
my $up = $network->{up};
while($up) {
$add_part_owner->($up);
$up = $up->{up};
}
$add_part_owner->($network->{zone});
$add_part_owner->($network->{zone});
}

# Substitute hash by array in attribute {part_owners}.
Expand Down Expand Up @@ -626,7 +626,7 @@ sub setup_part_owners {
# 1. Fill attribute {outer_owners} at hosts, interfaces and networks.
# For network, collect owners from enclosing networks and zone,
# that are different from networks owner.
# For host, collect owners of enclosing networks and zone,
# For host, collect owners of enclosing networks and zone,
# that are different from hosts owner.
# 2. Fill attribute {extended_by} for owners, with list of other owners
# of enclosing objects, that are allowed to watch that owner.
Expand All @@ -635,7 +635,7 @@ sub setup_part_owners {
# that are owned by the outer owner.
# Attribute {hide_from_outer_owners} is given at inner owner and hides
# from outer owners.
# Attribute {show_hidden_owners} at outer owner cancels effect of
# Attribute {show_hidden_owners} at outer owner cancels effect of
# {hide_from_outer_owners}
sub setup_outer_owners {
progress("Setup outer owners");
Expand Down Expand Up @@ -681,7 +681,7 @@ sub setup_outer_owners {
}

for my $network (@{ add_subnetworks($zone->{networks}) },
values %{ $zone->{ipmask2aggregate} })
values %{ $zone->{ipmask2aggregate} })
{
my %outer_owners;
my $net_owner = $network->{owner} || '';
Expand Down Expand Up @@ -753,8 +753,8 @@ sub export_no_nat_set {
my %owner2net;
for my $network (values %networks) {
$network->{disabled} and next;
for my $owner_name
(owner_for_object($network),
for my $owner_name
(owner_for_object($network),
part_owners_for_object($network),
outer_owners_for_object($network),
)
Expand Down Expand Up @@ -788,7 +788,7 @@ sub export_no_nat_set {
# }

# Build union of no_nat_sets
my $no_nat_set = [ sort(unique(map { keys(%{ $_->{no_nat_set} }) }
my $no_nat_set = [ sort(unique(map { keys(%{ $_->{no_nat_set} }) }
@nat_domains)) ];
# debug "$owner_name: ", join(',', sort @$no_nat_set);
$owner2no_nat_set{$owner_name} = $no_nat_set;
Expand Down Expand Up @@ -856,8 +856,8 @@ sub export_assets {
if (!$own_zone) {
my $net_owner = owner_for_object($net) || '';
if ($net_owner ne $owner) {
@childs =
grep({ my $o = owner_for_object($_); $o and $o eq $owner }
@childs =
grep({ my $o = owner_for_object($_); $o and $o eq $owner }
@childs);
}
}
Expand All @@ -870,7 +870,7 @@ sub export_assets {
};

# Different zones can use the same name from ipmask2aggregate
# '0/0' if they belong to the same zone_cluster.
# '0/0' if they belong to the same zone_cluster.
# Hence augment existing hash.
my $add_networks_hash = sub {
my ($owner, $name, $hash) = @_;
Expand Down Expand Up @@ -898,22 +898,22 @@ sub export_assets {
{
# debug "- $owner";
$add_networks_hash->(
$owner,
$zone_name,
$owner,
$zone_name,
$export_networks->($networks, $owner, 1));
}
for my $owner (part_owners_for_object($zone)) {

# Show only own or part_owned networks in foreign zone.
my $own_networks =
[ grep
{ grep({ $owner eq $_ }
my $own_networks =
[ grep
{ grep({ $owner eq $_ }
owner_for_object($_), part_owners_for_object($_)) }
@$networks ];
# debug "- $_->{name}" for @$own_networks;
$add_networks_hash->(
$owner,
$zone_name,
$owner,
$zone_name,
$export_networks->($own_networks, $owner, 0));
}
}
Expand Down Expand Up @@ -966,7 +966,7 @@ sub export_services {
my %owner2type2shash;
for my $service (@$normalized_services) {
my @rules = map {
{
{
action => $_->{action},
has_user => $_->{has_user},
src => [ sort map { $_->{name} } @{ $_->{src} } ],
Expand All @@ -982,15 +982,15 @@ sub export_services {
}

for my $owner ($service->{sub_owner} || (),
@{ $service->{owners} },
@{ $service->{owners} },
@{ $service->{part_owners} },
@{ $service->{outer_owners} })
{
$owner2type2shash{$owner}->{owner}->{$service} = $service;
}
for my $owner (@{ $service->{uowners} },
}
for my $owner (@{ $service->{uowners} },
@{ $service->{part_uowners} },
@{ $service->{outer_uowners} })
@{ $service->{outer_uowners} })
{
next if $owner2type2shash{$owner}->{owner}->{$service};
$owner2type2shash{$owner}->{user}->{$service} = $service;
Expand Down Expand Up @@ -1043,7 +1043,7 @@ sub export_users_and_service_lists {
my %service2users;
for my $type (qw(owner user visible)) {
my @snames;
for my $service (values %{ $type2shash->{$type} }) {
for my $service (values %{ $type2shash->{$type} }) {
(my $sname = $service->{name}) =~ s/^\w+://;
push @snames, $sname;
next if $type eq 'visible';
Expand Down Expand Up @@ -1102,8 +1102,8 @@ sub zone_and_subnet {

sub export_objects {
progress("Export objects");
my %objects = map {
$_->{name} => {
my %objects = map {
$_->{name} => {


# Add key 'ip' and optionally key 'nat'.
Expand All @@ -1115,7 +1115,7 @@ sub export_objects {
zone_and_subnet($_),

owner => scalar owner_for_object($_),
}
}
} values %all_objects;
export("objects", \%objects);
return;
Expand Down Expand Up @@ -1152,14 +1152,14 @@ sub export_owners {
push @e_owners, $e_owner->{name};
}

export("owner/$name/emails",
export("owner/$name/emails",
[ map { { email => $_ } } sort @emails ]);
export("owner/$name/watchers",
export("owner/$name/watchers",
[ map { { email => $_ } } sort @watchers ]);
export("owner/$name/extended_by",
export("owner/$name/extended_by",
[ map { { name => $_ } } sort @e_owners ]);
}

# Substitute hash by array.
$_ = [ sort values(%$_) ] for values %email2owners;

Expand All @@ -1184,7 +1184,7 @@ sub copy_policy_file {
####################################################################
# Initialize Netspoc data
####################################################################
$config =
$config =
combine_config({time_stamps => 1, max_errors => 9999, verbose => !$quiet});
init_global_vars();
read_file_or_dir($netspoc_data);
Expand Down

0 comments on commit 360eed0

Please sign in to comment.