11import { v4 as uuidv4 } from 'uuid' ;
22import { describe , expect , it } from 'vitest' ;
33import { createSyntheticStixObject } from '../../src/generator' ;
4- import {
5- type ExternalReferences
6- } from '../../src/schemas/common/index' ;
4+ import { type ExternalReferences } from '../../src/schemas/common/index' ;
75import { type LogSource , logSourceSchema } from '../../src/schemas/sdo/log-source.schema' ;
86
97describe ( 'logSourceSchema' , ( ) => {
@@ -22,10 +20,12 @@ describe('logSourceSchema', () => {
2220 {
2321 name : 'Security' ,
2422 channel : 'Security' ,
23+ data_component_name : 'Process Creation' ,
2524 } ,
2625 {
2726 name : 'System' ,
2827 channel : 'System' ,
28+ data_component_name : 'Process Creation' ,
2929 } ,
3030 ] ,
3131 } ;
@@ -39,14 +39,17 @@ describe('logSourceSchema', () => {
3939 {
4040 name : 'Application' ,
4141 channel : 'Application' ,
42+ data_component_name : 'Process Creation' ,
4243 } ,
4344 {
4445 name : 'Security' ,
4546 channel : 'Security' ,
47+ data_component_name : 'Process Creation' ,
4648 } ,
4749 {
4850 name : 'System' ,
4951 channel : 'System' ,
52+ data_component_name : 'Process Creation' ,
5053 } ,
5154 ] ,
5255 } ;
@@ -109,31 +112,55 @@ describe('logSourceSchema', () => {
109112 it ( 'should reject permutations with empty name' , ( ) => {
110113 const invalidObject = {
111114 ...minimalLogSource ,
112- x_mitre_log_source_permutations : [ { name : '' , channel : 'Security' } ] ,
115+ x_mitre_log_source_permutations : [
116+ { name : '' , channel : 'Security' , data_component_name : 'Security' } ,
117+ ] ,
113118 } ;
114119 expect ( ( ) => logSourceSchema . parse ( invalidObject ) ) . toThrow ( ) ;
115120 } ) ;
116121
117122 it ( 'should reject permutations with empty channel' , ( ) => {
118123 const invalidObject = {
119124 ...minimalLogSource ,
120- x_mitre_log_source_permutations : [ { name : 'Security' , channel : '' } ] ,
125+ x_mitre_log_source_permutations : [
126+ { name : 'Security' , channel : '' , data_component_name : 'Security' } ,
127+ ] ,
128+ } ;
129+ expect ( ( ) => logSourceSchema . parse ( invalidObject ) ) . toThrow ( ) ;
130+ } ) ;
131+
132+ it ( 'should reject permutations with empty data component name' , ( ) => {
133+ const invalidObject = {
134+ ...minimalLogSource ,
135+ x_mitre_log_source_permutations : [
136+ { name : 'Security' , channel : 'Security' , data_component_name : '' } ,
137+ ] ,
121138 } ;
122139 expect ( ( ) => logSourceSchema . parse ( invalidObject ) ) . toThrow ( ) ;
123140 } ) ;
124141
125142 it ( 'should reject permutations missing name' , ( ) => {
126143 const invalidObject = {
127144 ...minimalLogSource ,
128- x_mitre_log_source_permutations : [ { channel : 'Security' } ] ,
145+ x_mitre_log_source_permutations : [
146+ { channel : 'Security' , data_component_name : 'Security' } ,
147+ ] ,
129148 } ;
130149 expect ( ( ) => logSourceSchema . parse ( invalidObject ) ) . toThrow ( ) ;
131150 } ) ;
132151
133152 it ( 'should reject permutations missing channel' , ( ) => {
134153 const invalidObject = {
135154 ...minimalLogSource ,
136- x_mitre_log_source_permutations : [ { name : 'Security' } ] ,
155+ x_mitre_log_source_permutations : [ { name : 'Security' , data_component_name : 'Security' } ] ,
156+ } ;
157+ expect ( ( ) => logSourceSchema . parse ( invalidObject ) ) . toThrow ( ) ;
158+ } ) ;
159+
160+ it ( 'should reject permutations missing data component name' , ( ) => {
161+ const invalidObject = {
162+ ...minimalLogSource ,
163+ x_mitre_log_source_permutations : [ { name : 'Security' , channel : 'Security' } ] ,
137164 } ;
138165 expect ( ( ) => logSourceSchema . parse ( invalidObject ) ) . toThrow ( ) ;
139166 } ) ;
@@ -211,10 +238,12 @@ describe('logSourceSchema', () => {
211238 {
212239 name : 'Security' ,
213240 channel : 'Security' ,
241+ data_component_name : 'Security' ,
214242 } ,
215243 {
216244 name : 'Security' ,
217245 channel : 'Security' ,
246+ data_component_name : 'Security' ,
218247 } ,
219248 ] ,
220249 } ;
@@ -230,10 +259,12 @@ describe('logSourceSchema', () => {
230259 {
231260 name : 'Security' ,
232261 channel : 'Security' ,
262+ data_component_name : 'Security' ,
233263 } ,
234264 {
235265 name : 'Security' ,
236266 channel : 'Application' ,
267+ data_component_name : 'Security' ,
237268 } ,
238269 ] ,
239270 } ;
@@ -247,24 +278,27 @@ describe('logSourceSchema', () => {
247278 {
248279 name : 'Security' ,
249280 channel : 'EventLog' ,
281+ data_component_name : 'Security' ,
250282 } ,
251283 {
252284 name : 'Application' ,
253285 channel : 'EventLog' ,
286+ data_component_name : 'Security' ,
254287 } ,
255288 ] ,
256289 } ;
257290 expect ( ( ) => logSourceSchema . parse ( logSourceWithSameChannel ) ) . not . toThrow ( ) ;
258291 } ) ;
259292
260- it ( 'should handle very long permutation names and channels ' , ( ) => {
293+ it ( 'should handle very long permutation names, channels, and data component names ' , ( ) => {
261294 const longString = 'A' . repeat ( 1000 ) ;
262295 const logSourceWithLongStrings : LogSource = {
263296 ...minimalLogSource ,
264297 x_mitre_log_source_permutations : [
265298 {
266299 name : longString ,
267300 channel : longString ,
301+ data_component_name : longString ,
268302 } ,
269303 ] ,
270304 } ;
@@ -278,6 +312,7 @@ describe('logSourceSchema', () => {
278312 {
279313 name : 'Security/Application-Logs_2024' ,
280314 channel : 'Microsoft-Windows-Security-Auditing/Operational' ,
315+ data_component_name : 'Security' ,
281316 } ,
282317 ] ,
283318 } ;
0 commit comments