CASTHLAutomation is a Python-based automation tool designed to streamline the end-to-end process of analyzing multiple applications using CAST Highlight. It automates the workflow from fetching GitHub repository metadata, downloading and organizing source code, to triggering CAST Highlight onboarding and parsing results. The tool is highly configurable and supports batch processing, error handling, and detailed logging.
The main entry point is CASTHL_Automation.py
. The script is interactive and modular, allowing you to execute each step independently or as a sequence:
-
Download Metadata:
Fetches metadata for all repositories in a specified GitHub organization using the GitHub REST API. Metadata is saved as both JSON and CSV (Repositories_Summary.csv
). -
Download Source Code:
Downloads source code ZIPs for all repositories listed inRepositories_Summary.csv
. Supports batch processing (batch numbers are managed in the CSV). -
Unzip Source Code:
Extracts all downloaded ZIP files into a specified directory for further processing. -
Organize Application Folders:
Creates application folders and moves the corresponding repositories into them, based on mappings defined in the configuration. -
CAST Highlight Onboarding:
Triggers CAST Highlight analysis for each application using the Highlight Automation Command (Java JAR). Supports multi-threaded batch processing for efficiency. -
Log Parsing (Optional):
The tool can parse CAST Highlight logs to extract and summarize results, using the HLLogParser module.
- Python 3.x (with
pip
) - Java Development Kit (JDK)
- Perl (for Highlight Code Reader, if required)
- CAST Highlight Automation Command (Java JAR)
- Internet Connectivity (for GitHub and Highlight API access)
- GitHub Personal Access Token (with repo access)
- CAST Highlight API Token
-
Clone the Repository:
git clone <repo-url> cd CASTHLAutomation-main
-
Set Up Python Environment:
python -m venv venv venv\Scripts\activate pip install -r requirements.txt
-
Configure Properties:
- Edit
Config/config.properties
with your environment-specific paths, tokens, and settings. - (Optional) Edit
HLLogParser/config.properties
for log parsing.
- Edit
-
Prepare Input Files:
- Ensure
App-Repo-Mapping.xlsx
andapplications.txt
are present in theConfig
directory.
- Ensure
-
Navigate to the
src
Directory:cd src
-
Run the Main Script:
python CASTHL_Automation.py
-
Follow Interactive Prompts: The script will prompt you to select a step:
1. Download Metadata for GitHub organization. 2. Download source code for all repositories in the organization in batches. 3. Unzip the downloaded source code. 4. Create application folders and move repositories. 5. Copy or Append Mainframe folder to analyzed directory. 6. Get applications long path. 7. Trigger CAST Highlight onboarding for the source code. 8. Run all the steps in one go from 1 to 7.
Enter the step number to execute. You can run steps individually or in sequence.
-
Monitor Progress:
- Console output provides real-time status.
- Detailed logs are written to the directory specified in
logs_dir
.
Edit Config/config.properties
with the following sections:
github_org_name
: GitHub Organization Namegithub_token
: GitHub Personal Access Tokenlast_refresh_date
: Last refresh date (YYYY-MM-DD)
config_dir
: Path to configuration filessrc_dir
: Path to download source code ZIPsunzip_dir
: Path to extract source codelogs_dir
: Path for log filesoutput_dir
: Path for output filesmainframe_src_folder
: (Optional) Path for mainframe sourcessrc_dir_analyze
: Path for source files to be analyzedhighlight_perl_dir
: Path to Perl installationhighlight_analyzer_dir
: Path to Highlight analyzerRESULTS
: Path for analysis results
App_Repo_Mapping
: Path toApp-Repo-Mapping.xlsx
Keyword_Scan
: Path toKeywordScan.xml
highlight_application_mapping
: Path toapplications.txt
highlight_base_url
: CAST Highlight base URLhighlight_executable
: Path toHighlightAutomation.jar
highlight_company_id
: Company IDhighlight_token
: Highlight API tokenMAX_BATCHES
: Maximum number of batches (<=20)
IGNORED_DIR
,IGNORED_PATHS
,IGNORED_FILES
: Directories, paths, and files to ignore during analysis.
root_directory
: Path to HL Automation logsoutput_directory
: Path to HL Parser logsbearer_token
: API tokenapi_url
: Highlight API URLCompanyID
: Company ID
- Repositories_Summary.csv: Metadata for all repositories.
- Log Files: Detailed logs for each step and thread.
- Console Output: Real-time progress and error messages.
- Analysis Results: Output files in the specified
RESULTS
directory.
- Ensure all paths in
config.properties
are correct and accessible. - Check internet connectivity for GitHub and Highlight API access.
- Review log files for detailed error messages.
- Ensure all prerequisites (Python, Java, Perl, Highlight JAR) are installed and configured.
- Supports multi-threaded batch processing for efficiency.
- Modular: You can run each step independently.
- Ensure proper permissions for all directories and files.
- For security, do not commit your tokens or sensitive configuration to version control.
cd src
python CASTHL_Automation.py
# Enter step numbers as prompted (1-8)
For more details, refer to the comments and docstrings in the source