Cyber Trackr API Implementation Summary
What We Accomplished
1. OpenAPI Specification Enhancement
- Created comprehensive OpenAPI 3.1.1 specification for cyber.trackr.live API
- Enhanced with operationIds for clean method names
- Added x-extensions for documenting API behaviors
- Added links between related operations
- Added server variables for different environments
- Fixed tag naming (Documents instead of STIG/SRG) for cleaner API class names
2. Generated Ruby Client
Successfully generated Ruby client with clean method names:
list_all_documents()
instead ofstig_get()
get_document()
instead ofstig_title_version_release_get()
get_requirement()
for individual control details
3. Helper Methods (cyber_trackr_helper.rb)
Created convenience wrapper with methods:
fetch_complete_stig()
- Downloads complete STIG with all control detailslist_stigs()
/list_srgs()
- Filters mixed endpoint resultssearch_documents()
- Keyword search with type filteringget_latest_version()
- Finds most recent versiongenerate_compliance_summary()
- Severity breakdown
4. Comprehensive Test Suite
- Unit tests for helper methods (all passing)
- Integration tests for live API (mostly passing)
- Mock/fixture support for offline testing
Key Discoveries About the API
Data Format Quirks
- Released dates have leading spaces: " 30 Jan 2025"
- Some dates use full month names: " 23 January 2015" instead of "Jan"
- Some dates have single-digit days: " 3 May 2013" instead of "03"
- Empty date fields exist: Some older entries have "" for date
- Version field can have prefix: "V2" instead of just "2"
- Requirements are objects, not arrays: Keys are V-IDs (e.g., V-214518)
Generated Client Behavior
- Returns symbol keys instead of string keys in hashes
- Returns objects (DocumentVersion, RequirementSummary) not raw hashes
- Strict validation on all fields based on patterns
Known Issues
1. HTML Response for Individual Requirements (HANDLED)
When fetching individual requirements (e.g., /stig/Juniper_SRX_Services_Gateway_ALG/3/3/V-214518
), the API returns Content-Type: text/html; charset=UTF-8
even though the body is valid JSON.
Current Status: This issue is handled in the generated client's deserialize
method (lines 230-236) which detects when HTML content-type contains JSON data and parses it correctly. This fix was added directly to the generated code and allows all tests to pass.
Note: This fix will need to be reapplied if the client is regenerated from the OpenAPI spec.
The helper method fetch_complete_stig()
also includes error handling as an additional safety measure.
2. Field Name Inconsistencies
The API uses hyphenated field names in requirement details:
check-text
notcheck_text
fix-text
notfix_text
requirement-title
notrequirement_title
Our OpenAPI spec correctly documents these.
Usage Examples
require_relative 'cyber_trackr_helper'
client = CyberTrackrHelper::Client.new
# List all Juniper STIGs
juniper_stigs = client.search_documents('juniper', type: :stig)
# Get latest version of a STIG
latest = client.get_latest_version('Juniper_SRX_Services_Gateway_ALG')
# Fetch complete STIG with progress
complete_stig = client.fetch_complete_stig(
'Juniper_SRX_Services_Gateway_ALG',
'3',
'3'
) do |current, total, vuln_id|
puts "Fetching #{current}/#{total}: #{vuln_id}"
end
# Generate compliance summary
summary = client.generate_compliance_summary(
'Juniper_SRX_Services_Gateway_ALG',
'3',
'3'
)
puts "Total controls: #{summary[:total]}"
puts "High: #{summary[:by_severity][:high]}"
puts "Medium: #{summary[:by_severity][:medium]}"
puts "Low: #{summary[:by_severity][:low]}"
Next Steps
Fix HTML Response Issue: Investigate why individual requirement endpoints return HTML
- Possibly need to handle redirects differently
- May need to add redirect following to the generated client
- Could be a rate limiting or authentication issue
Add Caching: Consider adding caching to avoid repeatedly fetching the same data
Create Gem: Package as a proper gem for easier distribution
Add More Helper Methods:
- Batch download multiple STIGs
- Export to different formats (CSV, Excel, etc.)
- Diff between STIG versions