scenes Examine the environment Run code specific to the class of vulnerability Log security events Automatically check for Sqreen security rules updates While keeping the app fast.
we owe you one! Our beta customers raised different concerns: 1. Average response time 2. CPU consumption (mostly machine facing APIs) 3. Memory usage 4. Bandwidth
perf optimization Know what you are looking for Measure: understand precisely what need change Pareto law: 80% of execution time is spent in 20% of your code Change: just code it Evaluate: compare to previous measures Start over. Change Evaluate Measure
during a client request: doesn’t use network doesn’t interact with filesystem The decision to block is made in the application Back-end communication is performed in a dedicated thread Request processing Query
Low memory usage But it leaks! @samsaffron helped a lot Can be solved using context recycling ExecJS should be reset regularly memory (MB) 0 175 350 525 700 seconds 0 150 300 450 600
Reduce ExecJS spawn time Precompile everything Spawn ExecJS as less as possible We introduced pure Ruby pre-conditions Now the decision to call ExecJS is taken in Ruby
Perform analysis only on requests using a risky API Pick relevant methods The JS engine is spawned and performs further analysis Analyze Check if the API uses arguments that can be vulnerable Validate exposure If there is a security risk, we block the request and alert our back-end Alert & block if method.include?(watch_methods) if method_arg.include?(parameters) if ExecJS.is_an_attack? tell_thread_to_record_alert block_this_request end end end
Band- width Reducing memory usage leads to smaller objects to be treated, faster garbage collection Memory Reducing CPU usage leads to overall faster process CPU Less bandwidth means less server occupation and leads to faster responses Bandwidth Reducing I/O reduces time needed for tasks I/O Virtuous circle of optimization
not all about client How to reduce I/O time without changing the client? The exposed APIs need to respond faster We are applying the same method to our back-end