Skip to content

Commit 12db3a3

Browse files
committed
Add: Configuration to Limit KB usage per script
Currently it can happen, that script try to allocate huge amount of memory in the KB, which leads to flooding the RAM and crashing redis and openvas. The introduced config `max_mem_kb` limits the maximum KB traffic (in MB) to the specified value for a single script. Only written strings are tracked and only an estimation, as we do not know, if an item is replaced or appended. Also the key size is not counted as well. If the value is not set or <= 0, the maximum amount is unlimited (Default).
1 parent 5d324fa commit 12db3a3

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

ospd_openvas/daemon.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,24 @@
352352
+ 'scan package results.'
353353
),
354354
},
355+
'max_mem_kb': {
356+
'type': 'integer',
357+
'name': 'max_mem_kb',
358+
'default': 0,
359+
'mandatory': 0,
360+
'visible_for_client': True,
361+
'description': (
362+
'Maximum amount of memory (in MB) allowed to use for a single '
363+
+ 'script. If this value is set, the amount of memory put into '
364+
+ 'redis is tracked for every Script. If the amount of memory '
365+
+ 'exceeds this limit, the script is not able to set more kb '
366+
+ 'items. The tracked the value written into redis is only '
367+
+ 'estimated, as it does not check, if a value was replaced or '
368+
+ 'appended. The size of the key is also not tracked. If this '
369+
+ 'value is not set or <= 0, the maximum amount is unlimited '
370+
+ '(Default).'
371+
),
372+
},
355373
}
356374

357375

tests/test_daemon.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,24 @@
320320
+ 'scan package results.'
321321
),
322322
},
323+
'max_mem_kb': {
324+
'type': 'integer',
325+
'name': 'max_mem_kb',
326+
'default': 0,
327+
'mandatory': 0,
328+
'visible_for_client': True,
329+
'description': (
330+
'Maximum amount of memory (in MB) allowed to use for a single '
331+
+ 'script. If this value is set, the amount of memory put into '
332+
+ 'redis is tracked for every Script. If the amount of memory '
333+
+ 'exceeds this limit, the script is not able to set more kb '
334+
+ 'items. The tracked the value written into redis is only '
335+
+ 'estimated, as it does not check, if a value was replaced or '
336+
+ 'appended. The size of the key is also not tracked. If this '
337+
+ 'value is not set or <= 0, the maximum amount is unlimited '
338+
+ '(Default).'
339+
),
340+
},
323341
}
324342

325343

0 commit comments

Comments
 (0)