Skip to content

Commit

Permalink
More changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vakohl committed Jan 7, 2025
1 parent cfffb9b commit 70d810b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .script/tests/asimParsersTest/VerifyASimParserTemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ def extract_and_check_properties(Parser_file, Union_Parser__file, FileType, Pars
if match:
event_product = match.group(1)
results.append((event_product, '"EventProduct" field is mapped in parser', 'Pass'))
# if equivalent_built_in_parser end with Native, then use 'EventProduct' as SchemaName + 'NativeTable'
elif equivalent_built_in_parser.endswith('_Native'):
event_product = 'NativeTable'
results.append((event_product, '"EventProduct" field is not required since this is a native table parser. Static value will be used for "EventProduct".', 'Pass'))
# If 'EventProduct' was not found in the KQL query, add to results
else:
results.append((f'{RED}EventProduct{RESET}', f'{RED}"EventProduct" field not mapped in parser. Please map it in parser query.{RESET}', f'{RED}Fail{RESET}'))
Expand All @@ -136,6 +140,10 @@ def extract_and_check_properties(Parser_file, Union_Parser__file, FileType, Pars
if match:
event_vendor = match.group(1)
results.append((event_vendor, '"EventVendor" field is mapped in parser', 'Pass'))
# if equivalent_built_in_parser end with Native, then use 'EventVendor' as 'Microsoft'
elif equivalent_built_in_parser.endswith('_Native'):
event_vendor = 'Microsoft'
results.append((event_vendor, '"EventVendor" field is not required since this is a native table parser. Static value will be used for "EventVendor".', 'Pass'))
# If 'EventVendor' was not found in the KQL query, add to results
else:
results.append((f'{RED}EventVendor{RESET}', f'{RED}"EventVendor" field not mapped in parser. Please map it in parser query.{RESET}', f'{RED}Fail{RESET}'))
Expand Down
7 changes: 7 additions & 0 deletions .script/tests/asimParsersTest/ingestASimSampleData.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,18 @@ def extract_event_vendor_product(parser_query,parser_file):
match = re.search(r'EventVendor\s*=\s*[\'"]([^\'"]+)[\'"]', parser_query)
if match:
event_vendor = match.group(1)
# if equivalent_built_in_parser end with Native, then use 'EventVendor' as 'Microsoft'
elif equivalent_built_in_parser.endswith('_Native'):
event_vendor = 'Microsoft'
else:
print(f'EventVendor field not mapped in parser. Please map it in parser query.{parser_file}')

match = re.search(r'EventProduct\s*=\s*[\'"]([^\'"]+)[\'"]', parser_query)
if match:
event_product = match.group(1)
# if equivalent_built_in_parser end with Native, then use 'EventProduct' as SchemaName + 'NativeTable'
elif equivalent_built_in_parser.endswith('_Native'):
event_product = 'NativeTable'
else:
print(f'Event Product field not mapped in parser. Please map it in parser query.{parser_file}')
return event_vendor, event_product ,schema_name
Expand Down Expand Up @@ -332,6 +338,7 @@ def convert_data_type(schema_result, data_result):
parser_query = asim_parser.get('ParserQuery', '')
normalization = asim_parser.get('Normalization', {})
schema = normalization.get('Schema')
equivalent_built_in_parser = asim_parser.get('EquivalentBuiltInParser')
event_vendor, event_product, schema_name = extract_event_vendor_product(parser_query, file)

SampleDataFile = f'{event_vendor}_{event_product}_{schema}_IngestedLogs.csv'
Expand Down

0 comments on commit 70d810b

Please sign in to comment.