@@ -49,54 +49,43 @@ public void AddMatchRecord(MatchRecord matchRecord)
49
49
}
50
50
}
51
51
52
- // single standard properties we capture from any supported file type; others just captured as general tag matches...
53
- if ( matchRecord . Tags . Any ( v => v . Contains ( "Metadata.Application.Author" ) ) )
54
- {
55
- Metadata . Authors = ExtractValue ( matchRecord . Sample ) ;
56
- }
57
-
58
- if ( matchRecord . Tags . Any ( v => v . Contains ( "Metadata.Application.Publisher" ) ) )
59
- {
60
- Metadata . Authors = ExtractValue ( matchRecord . Sample ) ;
61
- }
62
-
63
- if ( matchRecord . Tags . Any ( v => v . Contains ( "Metadata.Application.Description" ) ) )
64
- {
65
- Metadata . Description = ExtractValue ( matchRecord . Sample ) ;
66
- }
67
-
68
- if ( matchRecord . Tags . Any ( v => v . Contains ( "Metadata.Application.Name" ) ) )
69
- {
70
- Metadata . ApplicationName = ExtractValue ( matchRecord . Sample ) ;
71
- }
72
-
73
- if ( matchRecord . Tags . Any ( v => v . Contains ( "Metadata.Application.Version" ) ) )
74
- {
75
- Metadata . SourceVersion = ExtractValue ( matchRecord . Sample ) ;
76
- }
77
-
78
- if ( matchRecord . Tags . Any ( v => v . Contains ( "Metadata.Application.Target.Processor" ) ) )
79
- {
80
- _ = Metadata . CPUTargets . TryAdd ( ExtractValue ( matchRecord . Sample ) . ToLower ( ) , 0 ) ;
81
- }
82
-
83
- if ( matchRecord . Tags . Any ( v => v . Contains ( "Metadata.Application.Output.Type" ) ) )
84
- {
85
- _ = Metadata . Outputs . TryAdd ( ExtractValue ( matchRecord . Sample ) . ToLower ( ) , 0 ) ;
86
- }
87
-
88
- if ( matchRecord . Tags . Any ( v => v . Contains ( "Platform.OS" ) ) )
89
- {
90
- _ = Metadata . OSTargets . TryAdd ( ExtractValue ( matchRecord . Sample ) . ToLower ( ) , 0 ) ;
91
- }
92
-
93
- if ( matchRecord . Tags . Any ( v => v . Contains ( "Metric." ) ) )
52
+ //Update metric counters for default or user specified tags; don't add as match detail
53
+ foreach ( var tag in matchRecord . Tags )
94
54
{
95
- Metadata . TagCounters . Add ( new MetricTagCounter ( )
55
+ switch ( tag )
96
56
{
97
- Tag = matchRecord . Tags [ 0 ] ,
98
- Count = 0
99
- } ) ;
57
+ case "Metadata.Application.Author" :
58
+ case "Metadata.Application.Publisher" :
59
+ Metadata . Authors = ExtractValue ( matchRecord . Sample ) ;
60
+ break ;
61
+ case "Metadata.Application.Description" :
62
+ Metadata . Description = ExtractValue ( matchRecord . Sample ) ;
63
+ break ;
64
+ case "Metadata.Application.Name" :
65
+ Metadata . ApplicationName = ExtractValue ( matchRecord . Sample ) ;
66
+ break ;
67
+ case "Metadata.Application.Version" :
68
+ Metadata . SourceVersion = ExtractValue ( matchRecord . Sample ) ;
69
+ break ;
70
+ case "Metadata.Application.Target.Processor" :
71
+ _ = Metadata . CPUTargets . TryAdd ( ExtractValue ( matchRecord . Sample ) . ToLower ( ) , 0 ) ;
72
+ break ;
73
+ case "Metadata.Application.Output.Type" :
74
+ _ = Metadata . Outputs . TryAdd ( ExtractValue ( matchRecord . Sample ) . ToLower ( ) , 0 ) ;
75
+ break ;
76
+ case "Platform.OS" :
77
+ _ = Metadata . OSTargets . TryAdd ( ExtractValue ( matchRecord . Sample ) . ToLower ( ) , 0 ) ;
78
+ break ;
79
+ default :
80
+ if ( tag . Contains ( "Metric." ) )
81
+ {
82
+ Metadata . TagCounters . Push ( new MetricTagCounter ( )
83
+ {
84
+ Tag = tag
85
+ } ) ;
86
+ }
87
+ break ;
88
+ }
100
89
}
101
90
102
91
//safeguard sample output now that we've matched properties for blocking browser xss
@@ -109,20 +98,16 @@ public void AddMatchRecord(MatchRecord matchRecord)
109
98
_ = Metadata . AppTypes . TryAdd ( solutionType , 0 ) ;
110
99
}
111
100
112
- //Update metric counters for default or user specified tags; don't add as match detail
113
- bool counterOnlyTag = false ;
114
- foreach ( MetricTagCounter counter in Metadata . TagCounters )
101
+ bool CounterOnlyTagSet = false ;
102
+ var selected = Metadata . TagCounters . Where ( x => matchRecord . Tags . Any ( y => y . Contains ( x . Tag ) ) ) ;
103
+ foreach ( var select in selected )
115
104
{
116
- if ( matchRecord . Tags . Any ( v => v . Contains ( counter . Tag ) ) )
117
- {
118
- counterOnlyTag = true ;
119
- counter . Count ++ ;
120
- break ;
121
- }
105
+ CounterOnlyTagSet = true ;
106
+ select . IncrementCount ( ) ;
122
107
}
123
108
124
- //omit adding if only a counter metric tag
125
- if ( ! counterOnlyTag )
109
+ //omit adding if ther a counter metric tag
110
+ if ( ! CounterOnlyTagSet )
126
111
{
127
112
//update list of unique tags as we go
128
113
foreach ( string tag in matchRecord . Tags )
0 commit comments