Skip to content

Commit

Permalink
[HACKATHON] Initial crack at an IdV matcher (#11624)
Browse files Browse the repository at this point in the history
* Initial crack at an IdV matcher

Matcher is a state machine that collects IDV "attempts" as they happen and tries to suss out interesting things about them.

[skip changelog]

* removed unused method

---------

Co-authored-by: Douglas Price <[email protected]>
  • Loading branch information
matthinz and solipet authored Dec 12, 2024
1 parent 9894989 commit 9dca95a
Show file tree
Hide file tree
Showing 4 changed files with 653 additions and 10 deletions.
15 changes: 5 additions & 10 deletions bin/summarize-user-events
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ Dir[File.expand_path(
end

class SummarizeUserEvents
attr_reader :uuid, :from_date, :to_date
attr_reader :uuid, :from_date, :to_date, :zone

def initialize(user_uuid: nil, start_time: nil, end_time: nil, zone: 'UTC')
@zone = zone
Time.zone = zone
@uuid = user_uuid
@from_date = parse_time(start_time) || 1.week.ago
Expand All @@ -41,11 +42,14 @@ class SummarizeUserEvents
def matchers
@matchers ||= [
EventSummarizer::ExampleMatcher.new,
EventSummarizer::IdvMatcher.new
]
end

def run
find_cloudwatch_events do |event|
Time.zone ||= zone

event['@message'] = JSON.parse(event['@message']) if event['@message'].is_a?(String)

matchers.each do |matcher|
Expand Down Expand Up @@ -90,15 +94,6 @@ class SummarizeUserEvents
QUERY
end

def find_events(&block)
warn "$stdin.tty? = #{$stdin.tty?}"
if $stdin.tty?
cloudwatch_source(&block)
else
stdin_source(&block)
end
end

def cloudwatch_client
@cloudwatch_client ||= Reporting::CloudwatchClient.new(
num_threads: 5,
Expand Down
Loading

0 comments on commit 9dca95a

Please sign in to comment.