1212use OCP \Security \Bruteforce \IThrottler ;
1313use Symfony \Component \Console \Input \InputArgument ;
1414use Symfony \Component \Console \Input \InputInterface ;
15+ use Symfony \Component \Console \Input \InputOption ;
1516use Symfony \Component \Console \Output \OutputInterface ;
1617
1718class BruteforceAttempts extends Base {
@@ -37,12 +38,20 @@ protected function configure(): void {
3738 InputArgument::OPTIONAL ,
3839 'Only count attempts for the given action ' ,
3940 )
41+ ->addOption (
42+ 'interval ' ,
43+ null ,
44+ InputOption::VALUE_REQUIRED ,
45+ 'Interval in hours to count attempts for (max 48) ' ,
46+ 12 ,
47+ )
4048 ;
4149 }
4250
4351 #[\Override]
4452 protected function execute (InputInterface $ input , OutputInterface $ output ): int {
4553 $ ip = $ input ->getArgument ('ipaddress ' );
54+ $ interval = (float )$ input ->getOption ('interval ' );
4655
4756 if (!filter_var ($ ip , FILTER_VALIDATE_IP )) {
4857 $ output ->writeln ('<error>" ' . $ ip . '" is not a valid IP address</error> ' );
@@ -54,12 +63,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5463 'attempts ' => $ this ->throttler ->getAttempts (
5564 $ ip ,
5665 (string )$ input ->getArgument ('action ' ),
66+ $ interval ,
5767 ),
5868 'delay ' => $ this ->throttler ->getDelay (
5969 $ ip ,
6070 (string )$ input ->getArgument ('action ' ),
6171 ),
6272 ];
73+ if ($ input ->getOption ('output ' ) === 'plain ' ) {
74+ $ data ['delay ' ] = $ data ['delay ' ] . ' ms ' ;
75+ }
6376
6477 $ this ->writeArrayInOutputFormat ($ input , $ output , $ data );
6578
0 commit comments