1. Go to this page and download the library: Download dgtlss/warden library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Dgtlss\Warden\Contracts\CustomAudit;
use Dgtlss\Warden\Enums\Severity;
use Dgtlss\Warden\ValueObjects\AuditContext;
use Dgtlss\Warden\ValueObjects\AuditResult;
use Dgtlss\Warden\ValueObjects\Finding;
final class PublicBucketAudit implements CustomAudit
{
public function getName(): string { return 'public-bucket'; }
public function getDescription(): string { return 'Checks the effective filesystem configuration.'; }
public function shouldRun(AuditContext $context): bool { return $context->profile === 'production'; }
public function run(AuditContext $context): AuditResult
{
$findings = config('filesystems.disks.s3.visibility') === 'public'
? [new Finding(
id: 'custom.storage.public',
source: $this->getName(),
title: 'S3 disk is public',
severity: Severity::High,
description: 'The default S3 disk visibility is public.',
remediation: 'Set the disk visibility to private.',
path: 'config/filesystems.php',
)]
: [];
return AuditResult::complete($this->getName(), $findings);
}
}