-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for checking expiry of intermediate certificates #54
Open
dweissengruber
wants to merge
7
commits into
maelstrom-cms:master
Choose a base branch
from
dweissengruber:ssl_check_intermediates
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
58ed94e
✨ Support for checking expiry of intermediate certificates
dweissengruber 135b690
🐛 Fix certificate_scan_id datatype
dweissengruber 8064ae6
🐛 ✔️ fix issue on add website
dweissengruber 8e00655
🐛 fix missing continue
dweissengruber 83dd404
✨ Update migration, ensure increment
dweissengruber 94edbeb
Revert "✨ Update migration, ensure increment"
dweissengruber 716c009
✨ comply with code style guidelines
dweissengruber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
trait HasIntermediateCertificates | ||
{ | ||
public function intermediate_certificates() | ||
{ | ||
$scan = $this->website->certificates()->latest()->first(); | ||
return $scan->hasMany(IntermediateCertificateScan::class); | ||
} | ||
|
||
public function getCertificateHostnameAttribute() | ||
{ | ||
return parse_url($this->url, PHP_URL_HOST); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class IntermediateCertificateScan extends Model | ||
{ | ||
protected $guarded = []; | ||
|
||
protected $casts = [ | ||
'common_name' => 'string', | ||
'valid_from' => 'datetime', | ||
'valid_to' => 'datetime', | ||
'was_valid' => 'boolean', | ||
'did_expire' => 'boolean', | ||
]; | ||
|
||
protected $appends = [ | ||
'expires_in', | ||
]; | ||
|
||
public function getExpiresInAttribute() | ||
{ | ||
return now()->diffAsCarbonInterval($this->valid_to)->forHumans(['join' => true]); | ||
} | ||
|
||
public function certificate() | ||
{ | ||
return $this->belongsTo(CertificateScan::class); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
database/migrations/2021_03_04_111337_create_intermediate_certificate_scans_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreateIntermediateCertificateScansTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('intermediate_certificate_scans', function (Blueprint $table) { | ||
$table->bigIncrements('id'); | ||
$table->bigInteger('certificate_scan_id')->unsigned()->index(); | ||
$table->foreign('certificate_scan_id')->references('id')->on('certificate_scans')->onDelete('cascade'); | ||
$table->string('issuer'); | ||
$table->string('common_name'); | ||
$table->dateTime('valid_from'); | ||
$table->dateTime('valid_to'); | ||
$table->boolean('was_valid'); | ||
$table->boolean('did_expire'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('intermediate_certificate_scans'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we "tidy" this whole block up to keep the code style more consistent with the rest of the project please?
e.g. single quotes, removing old array syntax, lowercase booleans etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be conform with your code style now :)