-
Notifications
You must be signed in to change notification settings - Fork 8
feat: AWS CloudTrail search command #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements a new AWS CloudTrail search command that allows users to search and filter CloudTrail logs without requiring Sigma rules. The implementation refactors common CLI options into reusable structs and updates the GeoIP integration to use a newer maxminddb API.
Key changes:
- Added
aws-ct-searchcommand with filtering by fields, keywords, regex, and time ranges - Refactored CLI options to create reusable
OutputOptionandSearchOptionsstructs - Updated GeoIP lookups to use the newer maxminddb
lookup().decode()API pattern
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/cmd/aws/aws_search.rs |
New search command implementation with filter/keyword/regex support and comprehensive unit tests |
src/cmd/aws.rs |
Registers the new aws_search module |
src/option/cli.rs |
Refactors output-related options into OutputOption struct and adds SearchOptions with display_order for consistent help text |
src/main.rs |
Integrates AwsCtSearch command with validation and dispatching logic |
src/core/util.rs |
Extracts load_profile function with skip_sigma parameter for reuse across commands |
src/core/timeline.rs |
Updates to use refactored OutputOption and new load_profile signature |
src/core/timeline_writer.rs |
Supports optional rules by changing write_record to accept Option<&Rule> |
src/core/scan.rs |
Updates to use refactored options.output_opt structure |
src/option/geoip.rs |
Updates GeoIP API usage from lookup::<T>() to lookup().decode::<T>() pattern |
Cargo.toml |
Adds regex = "1" dependency for regex search functionality |
Cargo.lock |
Updates dependency versions including regex and various transitive dependencies |
Comments suppressed due to low confidence (2)
src/option/geoip.rs:111
- The country value is not being cached when lookup succeeds but decode fails. When
country.decode()returnsErrorOk(None), the function returns "-" without caching this result. This means subsequent lookups for the same IP will repeatedly attempt to decode, which is inefficient. Consider caching the "-" result as well to avoid redundant lookups.
match self.country.lookup(ip) {
Ok(country) => {
let mut ret = "-";
if let Ok(Some(country)) = country.decode::<geoip2::Country>() {
let name_tree = country.country.names;
ret = name_tree.english.unwrap_or("")
}
ret.to_string()
}
_ => "-".to_string(),
}
src/option/geoip.rs:131
- The city value is not being cached when lookup succeeds but decode fails. When
city.decode()returnsErrorOk(None), the function returns "-" without caching this result. This means subsequent lookups for the same IP will repeatedly attempt to decode, which is inefficient. Consider caching the "-" result as well to avoid redundant lookups.
match self.city.lookup(ip) {
Ok(city) => {
let mut ret = "-";
if let Ok(Some(city)) = city.decode::<geoip2::City>() {
let name_tree = city.city.names;
ret = name_tree.english.unwrap_or("")
}
ret.to_string()
}
_ => "-".to_string(),
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
help |
-k, --keyword |
-r, --regex |
-F, --filter |
-t, --output-type (5: CSV & JSONL) |
-G, --geo-ip |
YamatoSecurity
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fukusuket LGTM! Thanks so much!!
What Changed
aws-ct-searchcommand #55Evidence
Integration-Test
I’d appreciate it if you could check it when you have time🙏