Skip to content

Concurrent security #261

Concurrent security

Concurrent security #261

Triggered via pull request July 21, 2023 15:40
Status Success
Total duration 1m 8s
Artifacts
This run and associated checks have been archived and are scheduled for deletion. Learn more about checks retention

mutation.yml

on: pull_request
Matrix: mutation / roave-infection
Fit to window
Zoom out
Zoom in

Annotations

10 warnings
mutation / PHP 8.1-ubuntu-latest: src/Counter.php#L74
Escaped Mutant for Mutator "FalseValue": --- Original +++ New @@ @@ public function hit(string $id) : CounterState { $attempts = 0; - $isFailStoreUpdatedData = false; + $isFailStoreUpdatedData = true; do { // Last increment time. // In GCRA it's known as arrival time.
mutation / PHP 8.1-ubuntu-latest: src/Counter.php#L106
Escaped Mutant for Mutator "Break_": --- Original +++ New @@ @@ $attempts++; if ($attempts >= $this->maxCasAttempts) { $isFailStoreUpdatedData = true; - break; + continue; } } while (true); return new CounterState($this->limit, $remaining, $resetAfter, $isFailStoreUpdatedData);
mutation / PHP 8.1-ubuntu-latest: src/Counter.php#L138
Escaped Mutant for Mutator "RoundingFamily": --- Original +++ New @@ @@ private function calculateRemaining(float $lastIncrementTimeInMilliseconds, float $theoreticalNextIncrementTime) : int { $incrementAllowedAt = $theoreticalNextIncrementTime - $this->periodInMilliseconds; - return (int) (round($lastIncrementTimeInMilliseconds - $incrementAllowedAt) / $this->incrementIntervalInMilliseconds); + return (int) (floor($lastIncrementTimeInMilliseconds - $incrementAllowedAt) / $this->incrementIntervalInMilliseconds); } private function getLastStoredTheoreticalNextIncrementTime(string $id) : ?float {
mutation / PHP 8.1-ubuntu-latest: src/Counter.php#L138
Escaped Mutant for Mutator "RoundingFamily": --- Original +++ New @@ @@ private function calculateRemaining(float $lastIncrementTimeInMilliseconds, float $theoreticalNextIncrementTime) : int { $incrementAllowedAt = $theoreticalNextIncrementTime - $this->periodInMilliseconds; - return (int) (round($lastIncrementTimeInMilliseconds - $incrementAllowedAt) / $this->incrementIntervalInMilliseconds); + return (int) (ceil($lastIncrementTimeInMilliseconds - $incrementAllowedAt) / $this->incrementIntervalInMilliseconds); } private function getLastStoredTheoreticalNextIncrementTime(string $id) : ?float {
mutation / PHP 8.1-ubuntu-latest: src/Counter.php#L174
Escaped Mutant for Mutator "Division": --- Original +++ New @@ @@ */ private function calculateResetAfter(float $theoreticalNextIncrementTime) : int { - return (int) ($theoreticalNextIncrementTime / self::MILLISECONDS_PER_SECOND); + return (int) ($theoreticalNextIncrementTime * self::MILLISECONDS_PER_SECOND); } /** * @return string Storage key used to store the next increment time.
mutation / PHP 8.1-ubuntu-latest: src/CounterState.php#L22
Escaped Mutant for Mutator "FalseValue": --- Original +++ New @@ @@ * @param int $resetTime Timestamp to wait until the rate limit resets. * @param bool $isFailStoreUpdatedData If fail to store updated the rate limit data. */ - public function __construct(private int $limit, private int $remaining, private int $resetTime, private bool $isFailStoreUpdatedData = false) + public function __construct(private int $limit, private int $remaining, private int $resetTime, private bool $isFailStoreUpdatedData = true) { } /**
mutation / PHP 8.1-ubuntu-latest: src/Policy/LimitPerIp.php#L13
Escaped Mutant for Mutator "Concat": --- Original +++ New @@ @@ { public function fingerprint(ServerRequestInterface $request) : string { - return sha1(strtolower($request->getMethod() . $request->getUri()->getPath() . $this->getIp($request))); + return sha1(strtolower($request->getMethod() . $this->getIp($request) . $request->getUri()->getPath())); } private function getIp(ServerRequestInterface $request) : string {
mutation / PHP 8.1-ubuntu-latest: src/Storage/ApcuStorage.php#L52
Escaped Mutant for Mutator "CastFloat": --- Original +++ New @@ @@ { /** @psalm-suppress MixedAssignment */ $value = apcu_fetch($key); - return is_int($value) || is_float($value) ? (float) $value / $this->fixPrecisionRate : null; + return is_int($value) || is_float($value) ? $value / $this->fixPrecisionRate : null; } }
mutation / PHP 8.1-ubuntu-latest: src/Storage/SimpleCacheStorage.php#L33
Escaped Mutant for Mutator "CastFloat": --- Original +++ New @@ @@ { /** @psalm-suppress MixedAssignment */ $value = $this->cache->get($key); - return is_int($value) || is_float($value) ? (float) $value : null; + return is_int($value) || is_float($value) ? $value : null; } }
mutation / PHP 8.1-ubuntu-latest: src/Time/MicrotimeTimer.php#L13
Escaped Mutant for Mutator "RoundingFamily": --- Original +++ New @@ @@ private const MILLISECONDS_PER_SECOND = 1000; public function nowInMilliseconds() : float { - return round(microtime(true) * self::MILLISECONDS_PER_SECOND); + return floor(microtime(true) * self::MILLISECONDS_PER_SECOND); } }