File tree 6 files changed +47
-3
lines changed
state/data-layer/wpcom/sites/scan 6 files changed +47
-3
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,11 @@ export interface Props {
18
18
diff ?: string ;
19
19
rows ?: Record < string , unknown > ;
20
20
table ?: string ;
21
+ primaryKeyColumn ?: string ;
22
+ value ?: string ;
21
23
filename ?: string ;
22
24
isFixable : boolean ;
25
+ details ?: Record < string , unknown > ;
23
26
}
24
27
25
28
class ThreatDescription extends PureComponent < Props > {
@@ -67,12 +70,18 @@ class ThreatDescription extends PureComponent< Props > {
67
70
}
68
71
69
72
renderDatabaseRows ( ) : ReactNode | null {
70
- const { rows , table } = this . props ;
71
- if ( ! rows || ! table ) {
73
+ const { table , details , primaryKeyColumn , value } = this . props ;
74
+ if ( ! table || ! details ) {
72
75
return null ;
73
76
}
74
77
75
- const content = Object . values ( rows ) . map ( ( row ) => JSON . stringify ( row ) + '\n' ) ;
78
+ const row = {
79
+ table,
80
+ primary_key_column : primaryKeyColumn ,
81
+ primary_key_value : value ,
82
+ details,
83
+ } ;
84
+ const content = JSON . stringify ( row , null , ' \t' ) + '\n' ;
76
85
77
86
return (
78
87
< >
Original file line number Diff line number Diff line change @@ -65,6 +65,14 @@ const getThreatMessage = ( threat: Threat ) => {
65
65
66
66
case 'database' :
67
67
if ( ! threat . rows ) {
68
+ if ( threat . table !== undefined ) {
69
+ return translate ( 'The database table %(table)s contains malicious code' , {
70
+ args : {
71
+ table : threat . table ,
72
+ } ,
73
+ } ) ;
74
+ }
75
+
68
76
return translate ( 'Database threat' ) ;
69
77
}
70
78
return translate (
Original file line number Diff line number Diff line change @@ -180,8 +180,11 @@ const ThreatItem: React.FC< Props > = ( {
180
180
diff = { threat . diff }
181
181
rows = { threat . rows }
182
182
table = { threat . table }
183
+ primaryKeyColumn = { threat . primaryKeyColumn }
184
+ value = { threat . value }
183
185
filename = { threat . filename }
184
186
isFixable = { isFixable }
187
+ details = { threat . details }
185
188
/>
186
189
187
190
< div className = "threat-item__buttons" >
Original file line number Diff line number Diff line change @@ -32,11 +32,14 @@ export interface BaseThreat {
32
32
extension ?: Extension ;
33
33
rows ?: Record < string , unknown > ;
34
34
table ?: string ;
35
+ primaryKeyColumn ?: string ;
36
+ value ?: string ;
35
37
diff ?: string ;
36
38
context ?: Record < string , unknown > ;
37
39
severity : number ;
38
40
source ?: string ;
39
41
version ?: string ;
42
+ details ?: Record < string , unknown > ;
40
43
}
41
44
42
45
export interface FixableThreat extends BaseThreat {
Original file line number Diff line number Diff line change @@ -105,6 +105,10 @@ export function getThreatType( threat: Threat ): ThreatType {
105
105
return 'database' ;
106
106
}
107
107
108
+ if ( threat . table !== undefined ) {
109
+ return 'database' ;
110
+ }
111
+
108
112
if ( 'Suspicious.Links' === threat . signature ) {
109
113
return 'database' ;
110
114
}
@@ -136,6 +140,20 @@ export const getThreatVulnerability = ( threat: Threat ): string | TranslateResu
136
140
return translate ( 'Vulnerability found in a theme' ) ;
137
141
138
142
case 'database' :
143
+ if ( threat . signature !== undefined ) {
144
+ return translate ( 'Thread found: %(signature)s' , {
145
+ args : {
146
+ signature : threat . signature ,
147
+ } ,
148
+ } ) ;
149
+ }
150
+ if ( threat . table !== undefined ) {
151
+ return translate ( 'The database table %(table)s contains malicious code' , {
152
+ args : {
153
+ table : threat . table ,
154
+ } ,
155
+ } ) ;
156
+ }
139
157
return 'Vulnerability found in a database table' ;
140
158
141
159
case 'none' :
Original file line number Diff line number Diff line change @@ -29,6 +29,9 @@ export const formatScanThreat = ( threat ) => ( {
29
29
rows : threat . rows ,
30
30
diff : threat . diff ,
31
31
table : threat . table ,
32
+ primaryKeyColumn : threat . pk_column ,
33
+ value : threat . value ,
34
+ details : threat . details ,
32
35
context : threat . context ,
33
36
severity : threat . severity ,
34
37
source : threat . source ,
You can’t perform that action at this time.
0 commit comments