Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
security_review
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
security_review
Commits
193a86c2
Commit
193a86c2
authored
2 years ago
by
Stephen Mustgrave
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#1244238
: Check that cron has been run recently - in the last 72 hours
parent
fd40a829
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!12
Issue #1244238: Check that cron has been run recently - in the last 72 hours
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
security_review.module
+2
-0
2 additions, 0 deletions
security_review.module
src/Checks/LastCronRun.php
+92
-0
92 additions, 0 deletions
src/Checks/LastCronRun.php
with
94 additions
and
0 deletions
security_review.module
+
2
−
0
View file @
193a86c2
...
...
@@ -16,6 +16,7 @@ use Drupal\security_review\Checks\FailedLogins;
use
Drupal\security_review
\Checks\Field
;
use
Drupal\security_review
\Checks\FilePermissions
;
use
Drupal\security_review
\Checks\InputFormats
;
use
Drupal\security_review
\Checks\LastCronRun
;
use
Drupal\security_review
\Checks\PrivateFiles
;
use
Drupal\security_review
\Checks\QueryErrors
;
use
Drupal\security_review
\Checks\TemporaryFiles
;
...
...
@@ -41,6 +42,7 @@ function security_review_security_review_checks() {
new
TrustedHosts
(),
new
UploadExtensions
(),
new
ViewsAccess
(),
new
LastCronRun
(),
];
}
...
...
This diff is collapsed.
Click to expand it.
src/Checks/LastCronRun.php
0 → 100644
+
92
−
0
View file @
193a86c2
<?php
namespace
Drupal\security_review\Checks
;
use
Drupal\Core\Link
;
use
Drupal\security_review
\Check
;
use
Drupal\security_review
\CheckResult
;
use
Drupal\user\Entity\Role
;
use
Drupal\user\Entity\User
;
/**
* Checks the last time cron has ran.
*/
class
LastCronRun
extends
Check
{
/**
* {@inheritdoc}
*/
public
function
getNamespace
()
{
return
'Security Review'
;
}
/**
* {@inheritdoc}
*/
public
function
getTitle
()
{
return
'Last cron run'
;
}
/**
* {@inheritdoc}
*/
public
function
getMachineTitle
()
{
return
'last_cron_run'
;
}
/**
* {@inheritdoc}
*/
public
function
run
()
{
$result
=
CheckResult
::
SUCCESS
;
$last_run
=
TRUE
;
$cron_last
=
\Drupal
::
state
()
->
get
(
'system.cron_last'
);
if
(
$cron_last
<=
strtotime
(
'-3 day'
))
{
$result
=
CheckResult
::
FAIL
;
$last_run
=
FALSE
;
}
return
$this
->
createResult
(
$result
,
[
'last_run'
=>
$last_run
]);
}
/**
* {@inheritdoc}
*/
public
function
help
()
{
$paragraphs
=
[];
$paragraphs
[]
=
$this
->
t
(
'A properly configured cron job executes, initiates, or manages a variety of tasks.'
);
return
[
'#theme'
=>
'check_help'
,
'#title'
=>
$this
->
t
(
'Cron has ran in last 3 days.'
),
'#paragraphs'
=>
$paragraphs
,
];
}
/**
* {@inheritdoc}
*/
public
function
evaluatePlain
(
CheckResult
$result
)
{
if
(
$result
->
result
()
!=
CheckResult
::
FAIL
)
{
return
''
;
}
return
$this
->
t
(
'Last cron run'
);
}
/**
* {@inheritdoc}
*/
public
function
getMessage
(
$result_const
)
{
switch
(
$result_const
)
{
case
CheckResult
::
SUCCESS
:
return
$this
->
t
(
'Cron has ran within the last 3 days.'
);
case
CheckResult
::
FAIL
:
return
$this
->
t
(
'Cron has not ran within the last 3 days.'
);
default
:
return
$this
->
t
(
'Unexpected result.'
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment