This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Accept
Reject

NetWitness Community

  • Home
  • Products
    • NetWitness Platform
      • Advisories
      • Documentation
        • Platform Documentation
        • Known Issues
        • Security Fixes
        • Hardware Documentation
        • Threat Content
        • Unified Data Model
        • Videos
      • Downloads
      • Integrations
      • Knowledge Base
    • NetWitness Cloud SIEM
      • Advisories
      • Documentation
      • Knowledge Base
    • NetWitness Detect AI
      • Advisories
      • Documentation
      • Knowledge Base
    • NetWitness Investigator
    • NetWitness Orchestrator
      • Advisories
      • Documentation
      • Knowledge Base
      • Legacy NetWitness Orchestrator
        • Advisories
        • Documentation
  • Community
    • Blog
    • Discussions
    • Events
    • Idea Exchange
  • Support
    • Case Portal
      • Create New Case
      • View My Cases
      • View My Team's Cases
    • Community Support
      • Getting Started
      • News & Announcements
      • Community Support Forum
      • Community Support Articles
    • Product Life Cycle
    • Support Information
    • General Security Advisories
  • Training
    • Blog
    • Certification Program
    • Course Catalog
    • New Product Readiness
    • On-Demand Subscriptions
    • Student Resources
    • Upcoming Events
  • Technology Partners
  • Trust Center
Sign InRegister Now
cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Search instead for 
Did you mean: 
NetWitness Discussions
  • NetWitness Community
  • Discussions
  • EPL: context with enrichment
  • Options
    • Subscribe to RSS Feed
    • Mark Topic as New
    • Mark Topic as Read
    • Float this Topic for Current User
    • Bookmark
    • Subscribe
    • Mute
    • Printer Friendly Page

EPL: context with enrichment

BohdanR
BohdanR Occasional Contributor
Occasional Contributor
Options
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

‎2021-09-14 11:24 AM

I am trying to write a rule that will create alert on login out of office hours, while using a context-hub list enrichment containing whitelist of users that are allowed to do that.

For imagination, simplified version of the rule is:

create context OOHours start (0, 20, *, *, [1,2,3,4,5], *, 'Europe/Paris') end (30, 7, *, *, [1,2,3,4,5], *, 'Europe/Paris');

@Name("Login out of office hours")
@UsesEnrichment(name = 'OOH_WL')
@RSAAlert

context OOHours
SELECT * FROM Event(
device_type = 'winevent_nic' AND
NOT EXISTS (SELECT * FROM OOH_WL WHERE name = Event.user_src_lower )
);

 

The problem is that when I try to deploy such rule, I receive an error:  Named window by name 'OOH_WL' has been declared for context 'null' and can only be used within the same context

If I try to put @UsesEnrichment under context OOHours, it thows a syntax error. 

Any ideas how to solve it, to be able to use context and enrichment at the same time?

 

I know I could use another approach by checking esa_time or event_time using functions like getHourOfDay, but those times are in GMT and office hour are in local time zone (CET), so it changes with winter time and summer time twice a year, and I don't know how to convert GMT to local time in EPL...

Labels:
  • Labels:
  • RSA NetWitness Platform
  • context
  • context hub list
  • enrichment
  • EPL
  • time zone
0 Likes
Share
Reply
  • All forum topics
  • Previous Topic
  • Next Topic
2 REPLIES 2

JoshRandall
Valued Contributor JoshRandall Valued Contributor
Valued Contributor
Options
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

‎2021-09-14 12:01 PM - edited ‎2021-09-14 12:04 PM

@BohdanR I don't know if there's a way to use both a CH List and a context at the same time, but you can use local time zone offsets in your contexts like so....

 

 

CREATE SCHEMA BeginNonWorkingHours();
CREATE SCHEMA EndNonWorkingHours();
CREATE CONTEXT NonWorkingHours START BeginNonWorkingHours END EndNonWorkingHours;

/*
SET YOUR TZ OFFSET WITH EITHER .minus(N hours) OR .plus(N hours)
the below syntax is for US PST -8 hour offset
and would be changed during daylight saving to a -7 hour offset
PST time: Mon-Fri 0800 - 1759
*/
INSERT INTO BeginNonWorkingHours
SELECT * FROM PATTERN[
	EVERY timer:interval(1 minute)
	]
	WHERE(
		(
		current_timestamp.minus(8 hours).getDayOfWeek IN [2:6]
		AND
		current_timestamp.minus(8 hours).getHourOfDay NOT IN [08:17]
		)
	);

/*
SET YOUR TZ OFFSET WITH EITHER .minus(N hours) OR .plus(N hours)
the below syntax is for US PST -8 hour offset
and would be changed during daylight saving to a -7 hour offset
PST time: Mon-Fri 0800 - 1759
*/
INSERT INTO EndNonWorkingHours
SELECT * FROM PATTERN[
	EVERY timer:interval(1 minute)
	]
	WHERE(
		(
		current_timestamp.minus(8 hours).getDayOfWeek IN [2:6]
		AND
		current_timestamp.minus(8 hours).getHourOfDay IN [08:17]
		)
	);

@RSAAlert(oneInSeconds=0, identifiers={"user_dst"})
@Name("Failed Logins Outside Business Hours by {user_dst}")
context NonWorkingHours select window(*) from Event
         (medium =32
          AND ec_activity='Logon'
		  AND ec_outcome='Failure'
		  AND device_class IS NOT NULL
		  AND user_dst IS NOT NULL
		  AND user_dst NOT LIKE '%$'
		 ).win:time(1800 seconds) group by user_dst having count(*) = 2 output first every 1800 seconds;

 

 

This has the added benefit of accounting for both weekends and weekdays, in addition to the timezone offset.


Mr. Mongo
0 Likes
Share
Reply

BohdanR
BohdanR Occasional Contributor
Occasional Contributor
In response to JoshRandall
Options
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

‎2021-09-14 12:18 PM - edited ‎2021-09-14 12:20 PM

Hi Josh,

I am not sure if that can help me, because as I mentioned, I need to use a whitelist stored in a contexthub list (which is actually created by export of AD group) in the rule. Your sample also uses context, so I suppose I would have the same problem there.

In addition, the problem with offset is, that we have it +1 hour in the winter, but +2 hours in the summer. And I will not remember to update all such rules twice a year when we switch to summer/winter time 🙂 I suppose it would require using some Java functions to calculate local time automatically...

 

By the way, what I used in my sample rule, defining context with a time zone as following, works with the local time correctly (the problem is just how to use an enrichment with it):
create context WorkingHours start (0, 8, *, *, [1,2,3,4,5], *, 'Europe/Paris') end (0, 17, *, *, [1,2,3,4,5], *, 'Europe/Paris');

0 Likes
Share
Reply
Powered by Khoros
  • Blog
  • Events
  • Discussions
  • Idea Exchange
  • Knowledge Base
  • Case Portal
  • Community Support
  • Product Life Cycle
  • Support Information
  • About the Community
  • Terms & Conditions
  • Privacy Statement
  • Acceptable Use Policy
  • Employee Login
© 2022 RSA Security LLC or its affiliates. All rights reserved.