<commit_before># segmentCalc.py
Processes segments xml from ForeScout CounterACT and returns a modified xml including all RFC 1918 not explicitly defined in original file

usagage: segmentCalc.py --xml filename --out directory --segment <segment name to append results in xml>

Author: offsecNoob
Date: 6/17/2017
Background:


ForeScout CounterACT is a network access control solution. The tool monitors and responds to hosts in defined 
network segments. However, there are many good cases for wanting to monitor and respond to all networks. ForeScout CounterACTcan 
see all networks however, it only actively responds and processes policies for the defined networks. 
In other words if you want ForeScout to monitor and respond to all potential networks you must define all potential
networks. This isn't as easy as it sounds because you are not allowed to define segments that overlap other segments.
Large organizations can have hundreds possibly thousnads of subnets. Findind the ones not in use (not defined segments)
without overlapping other segments isn't easy.


Objective:

The objective of this script is to take a ForeScout CounterACT segments export xml file, parse it and normalize all the 
defined segment ranges then determine the cidr(s) that cover those ranges.

Some organizations may have non-standard subnetting so it attempts to accomodate those as well.

The script makes use of the netaddr library to easily manipulate ip, ip ranges, ip networks, cidrs and ipsets. The script
uses built in netaddr "diff" function to subtract the parsed list of segement ranges from all priavte network ranges RFC 1918.
The Script then appends a child to the resulting ranges that aren't explicitly defined to a specified segment(cli arg) node.
The new ranges are assigned to a node named "unassigned" so it easily recognizeable when imported back into CounterACT.
Finally the script outputs the results into a new valid xml segments file that can be imported back into forescout. This
script should be run any time major change are made to defined segments. 




Future Work:
logging, better debugging/exception handling, simplification of code
<commit_msg>spelling<commit_after># segmentCalc.py
Processes segments xml from ForeScout CounterACT and returns a modified xml including all RFC 1918 not explicitly defined in original file

usage: segmentCalc.py --xml filename --out directory --segment <segment name to append results in xml>

Author: offsecNoob
Date: 6/17/2017
Background:


ForeScout CounterACT is a network access control solution. The tool monitors and responds to hosts in defined 
network segments. However, there are many good cases for wanting to monitor and respond to all networks. ForeScout CounterACTcan 
see all networks however, it only actively responds and processes policies for the defined networks. 
In other words if you want ForeScout to monitor and respond to all potential networks you must define all potential
networks. This isn't as easy as it sounds because you are not allowed to define segments that overlap other segments.
Large organizations can have hundreds possibly thousnads of subnets. Findind the ones not in use (not defined segments)
without overlapping other segments isn't easy.


Objective:

The objective of this script is to take a ForeScout CounterACT segments export xml file, parse it and normalize all the 
defined segment ranges then determine the cidr(s) that cover those ranges.

Some organizations may have non-standard subnetting so it attempts to accomodate those as well.

The script makes use of the netaddr library to easily manipulate ip, ip ranges, ip networks, cidrs and ipsets. The script
uses built in netaddr "diff" function to subtract the parsed list of segement ranges from all priavte network ranges RFC 1918.
The Script then appends a child to the resulting ranges that aren't explicitly defined to a specified segment(cli arg) node.
The new ranges are assigned to a node named "unassigned" so it easily recognizeable when imported back into CounterACT.
Finally the script outputs the results into a new valid xml segments file that can be imported back into forescout. This
script should be run any time major change are made to defined segments. 




Future Work:
logging, better debugging/exception handling, simplification of code

{'fraction_non_alphanumeric': 0.028208092485549133, 'fraction_numerical': 0.006936416184971098, 'mean_word_length': 4.775700934579439, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6283704', 'n_tokens_mistral': 1054, 'n_tokens_neox': 975, 'n_words': 656}