Fix audit command to exit with amount of advisories matched
parent
e3c46cb2b2
commit
658f56ff13
|
@ -47,7 +47,8 @@ EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
$auditor = new Auditor($httpDownloader);
|
$auditor = new Auditor($httpDownloader);
|
||||||
return $auditor->audit($this->getIO(), $packages, $this->getAuditFormat($input, 'format'), false);
|
|
||||||
|
return min(255, $auditor->audit($this->getIO(), $packages, $this->getAuditFormat($input, 'format'), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Auditor
|
||||||
* @param PackageInterface[] $packages
|
* @param PackageInterface[] $packages
|
||||||
* @param self::FORMAT_* $format The format that will be used to output audit results.
|
* @param self::FORMAT_* $format The format that will be used to output audit results.
|
||||||
* @param bool $warningOnly If true, outputs a warning. If false, outputs an error.
|
* @param bool $warningOnly If true, outputs a warning. If false, outputs an error.
|
||||||
* @return int
|
* @return int Amount of advisories found
|
||||||
* @throws InvalidArgumentException If no packages are passed in
|
* @throws InvalidArgumentException If no packages are passed in
|
||||||
*/
|
*/
|
||||||
public function audit(IOInterface $io, array $packages, string $format, bool $warningOnly = true): int
|
public function audit(IOInterface $io, array $packages, string $format, bool $warningOnly = true): int
|
||||||
|
@ -56,9 +56,12 @@ class Auditor
|
||||||
$punctuation = $format === 'summary' ? '.' : ':';
|
$punctuation = $format === 'summary' ? '.' : ':';
|
||||||
$io->writeError("<$errorOrWarn>Found $numAdvisories security vulnerability advisor{$plurality}{$punctuation}</$errorOrWarn>");
|
$io->writeError("<$errorOrWarn>Found $numAdvisories security vulnerability advisor{$plurality}{$punctuation}</$errorOrWarn>");
|
||||||
$this->outputAdvisories($io, $advisories, $format);
|
$this->outputAdvisories($io, $advisories, $format);
|
||||||
return 1;
|
|
||||||
|
return count($advisories);
|
||||||
}
|
}
|
||||||
|
|
||||||
$io->writeError('<info>No security vulnerability advisories found</info>');
|
$io->writeError('<info>No security vulnerability advisories found</info>');
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue