Program architecture and Classes¶
Modules and Classes and Methods docs.¶
The following are the documentation for Modules, Classes, and Methods.
Process flow¶
The following is overview of process flow. You would be better off checking the python code, because the process is simple and easy.
[Initializing]¶
1. Process start.
2. Creating basic class objects: ObjectFactory
3. Parsing command arguments and reading from STDIN.
4. Detecting mode: Survey-mode
The following is description of “Survey IPs” mode.
5. Creating each class objects: ObjectFactory
[Process in each input row]¶
The data is passed by
ValueDataobject in each processes.
6. Parsing the target: TargetParser, Target
7. Finding the group: TargetGroup
8. Collecting the source data: DataCollector, Requester
9. Outputting the result: Serializer
[Back to primary flow]¶
10. Process complete.
Survey-mode¶
“ipsurv” have two Survey-mode. Those are “Survey IPs” and “Survey Self”.
Survey-mode |
Filename |
Class |
|---|---|---|
Survey IPs |
survey_ips.py |
|
Survey Self |
survey_self.py |
|
Configure and Constant¶
The following is description of Configure and Constant.
Class |
Filename |
Description |
|---|---|---|
|
./configure/args_builder.py |
Building args object. |
Validator classes |
./configure/args_validators.py |
Arguments specifying complex conditions. |
config.py |
Configure class. There are various configure variables. Example: config_customize.py |
|
|
config.py |
Constant class. |
ObjectFactory¶
ObjectFactory class provide customizing classes and creating original classes. Important classes are generated in ObjectFactory.
If you’d like to create original factory class , extending ObjectFactory. And injecting to IpSurvCmd class.
Attribute |
Value |
|---|---|
Class |
|
Path |
./core/object_factory.py |
Example |
object_factory_original_headers.py |
ValueData¶
ValueData class is the role of storing data. It’s used by various process. ValueData object is created by ValueDataFactory.
You are able to customize ValueData class by ValueDataFactory class.
Attribute |
Value |
|---|---|
Class |
ValueData, ValueDataFactory |
Path |
./core/entity.py |
Target¶
Target class is the role of target data for surveying. It includes “IP”, “URL”, “FQDN”, “port” or any other source data.
Target object is created by TargetParser class. And Target object is stored as “target” in ValueData object, outputting with the name “target.*” in serializing.
Attribute |
Value |
|---|---|
Class |
|
Path |
./core/entity.py |
Example |
target_parser_customize.py |
TargetParser¶
TargetParser class is the role of parsing input row and creating Target object. You are able to customize parsing process, and store original source data.
Attribute |
Value |
|---|---|
Class |
|
Path |
./core/target_parser.py |
Example |
target_parser_customize.py |
Pipeline¶
Pipeline class provide catching and customizing the data in each processing. Pipeline class allows for modifying process behaviors or adding specifications without a lot of class extensions or changing the structure.
It’s available to very fine data control.
Attribute |
Value |
|---|---|
Class |
|
Path |
./core/pipeline.py |
Example |
pipeline_customize.py |
Pipeline’s methods
When Pipeline’s methods are dispatched:
Methods |
When it dispatch |
Processing e.g. |
|---|---|---|
|
Initializing arguments values. |
Customizing arguments and env. |
|
Before configuring arguments. |
Customizing arguments before configuring. |
|
After configuring arguments. |
Customizing arguments after configuring. |
|
Detecting Survey-mode. |
Changing Survey-mode. |
|
Before beginning processes. |
Initializing. |
|
Before parsing the target. |
Check or Modify row data before parsing. |
|
Before identifying the target. |
Customizing parsed data. |
|
Before outputting headers. |
Customizing headers. |
|
Before collecting for each row. |
|
|
When finding the group. |
Customizing grouping. |
|
When identifying the group. |
Customizing grouping. |
|
After identifying the group and creating the group. |
Customizing grouping. |
|
Before collecting each data collection. |
|
|
After collecting each data collection. |
Customizing response data. |
|
After collecting for each row. |
Customizing collected data. |
|
Building the output data and transforming data. |
Customizing output data. |
|
When a system error occurs and building error data. |
|
|
When outputting result in each process. |
Customizing outputting result. |
|
In self-mode, when outputting the result. |
|
|
After completing processes. |
Final processing. |
DataCollector¶
DataCollector class provide call Requester class and collect response data. Approximately, DataCollector class can be considered a wrapper class for Request class.
Attribute |
Value |
|---|---|
Class |
|
Path |
./data_collector/data_collector.py, Classes in the same hierarchy. |
Example |
check_wordpress_site.py |
Requester¶
Requester class provide requesting outer data.
Attribute |
Value |
|---|---|
Class |
|
Path |
./requester/requester.py, Classes in the same hierarchy. |
Example |
check_favicon.py, use_requester_directly.py |
Serializer¶
Serializer class provide displaying data and transforming data for presentation. LineSerializer class provide feature of line output. JsonSerializer class provide JSON output. Also, you are able to create original Serializer.
Attribute |
Value |
|---|---|
Class |
Serializer, LineSerializer, JsonSerializer |
Path |
./serializer/serializer.py, line_serializer.py, json_serializer.py |
Example |
object_factory_original_headers.py |
Serializer’s methods
Serializer’s methods:
Methods |
Description |
|---|---|
|
Set the survey mode. |
|
Set the delimiter (separator character). |
|
Output in beginning the process. |
|
Create labels. |
|
Get a specified label. |
|
Set the status of the process. |
|
Build the data structure. |
|
Transforms the data. |
|
Filters value. |
|
Build a row. |
|
Build error. |
|
Output the result. |
|
Output the value. |
|
Output in completing the process. |
|
Transforms key labels. |
|
Outputs a message. |
|
Output an item. |
Utils¶
In ./util, there are some util classes. Those are used in various places.
Path |
Classes |
|---|---|
./util/args_util.py |
|
./util/network_util.py |
|
./util/sys_util.py |
|
Internal specifications / Misc¶
About “RDAP” Data¶
RDAP data is JSON data by RDAP structure. However, the data like country code is not perfect. There is not country code rarely. In such cases, the country code is analyzed from the address.
In rare cases, the RDAP server’s data may be incorrect.
About “DNSTXT” Data¶
“DNSTXT” data is collected from TXT-record of “origin.asn.cymru.com”.
About “IPINFO” Data¶
“IPINFO” data is collected from “ipinfo.io”.