Skip to content
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

1.6.0 #85

Merged
merged 10 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ This should print the Kirby CLI version and a list of available commands
- kirby register
- kirby remove:command
- kirby roots
- kirby security
- kirby unzip
- kirby upgrade
- kirby uuid:generate
Expand Down Expand Up @@ -300,7 +301,8 @@ return [
- **[Forum](https://forum.getkirby.com)** – Whenever you get stuck, don't hesitate to reach out for questions and support.
- **[Discord](https://chat.getkirby.com)** – Hang out and meet the community.
- **[YouTube](https://youtube.com/kirbyCasts)** - Watch the latest video tutorials visually with Bastian.
- **[Mastodon](https://mastodon.social/@getkirby)** – Spread the word.
- **[Mastodon](https://mastodon.social/@getkirby)** – Follow us in the Fediverse.
- **[Bluesky](https://bsky.app/profile/getkirby.com)** – Follow us on Bluesky.
- **[Instagram](https://www.instagram.com/getkirby/)** – Share your creations: #madewithkirby.

---
Expand Down
6 changes: 3 additions & 3 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ function bootstrap(): string|null
// avoid any output in the CLI
$_ENV['KIRBY_RENDER'] = false;

if (empty($_ENV['KIRBY_HOST']) === false) {
$_SERVER['SERVER_NAME'] = $_ENV['KIRBY_HOST'];
$_SERVER['HTTP_HOST'] = $_ENV['KIRBY_HOST'];
if ($host = getenv('KIRBY_HOST')) {
$_SERVER['SERVER_NAME'] = $host;
$_SERVER['HTTP_HOST'] = $host;
}

ob_start();
Expand Down
57 changes: 57 additions & 0 deletions commands/security.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

declare(strict_types = 1);

use Kirby\CLI\CLI;
use Kirby\Http\Remote;
use Kirby\Http\Url;
use Kirby\Toolkit\I18n;

return [
'description' => 'Performs security checks of the site',
'command' => static function (CLI $cli): void {
$kirby = $cli->kirby();
$system = $kirby->system();
$updateStatus = $system->updateStatus();
$messages = [
...array_column($updateStatus?->messages() ?? [], 'text'),
...$updateStatus->exceptionMessages()
];

if ($kirby->option('debug', false) === true) {
$messages[] = I18n::translate('system.issues.debug');
}

if ($kirby->environment()->https() !== true) {
$messages[] = I18n::translate('system.issues.https');
}

// checks exposable urls of the site
// works only site url is absolute since can't get it in CLI mode
// and CURL won't work for relative urls
if (Url::isAbsolute($kirby->url())) {
$urls = [
'content' => $system->exposedFileUrl('content'),
'git' => $system->exposedFileUrl('git'),
'kirby' => $system->exposedFileUrl('kirby'),
'site' => $system->exposedFileUrl('site')
];

foreach ($urls as $key => $url) {
if (empty($url) === false && Remote::get($url)->code() < 400) {
$messages[] = I18n::translate('system.issues.' . $key);
}
}
} else {
$messages[] = 'Could not check for exposed folders as the site URL is not absolute';
}

if (empty($messages) === false) {
foreach ($messages as $message) {
$cli->error('> ' . $message);
}
} else {
$cli->success('Basic security checks were successful, please review https://getkirby.com/docs/guide/security for additional best practices.');
}
}
];
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "getkirby/cli",
"description": "Kirby command line interface",
"license": "MIT",
"version": "1.5.0",
"version": "1.6.0",
"keywords": [
"kirby",
"cms",
Expand All @@ -27,8 +27,8 @@
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"ext-zip": "*",
"composer-runtime-api": "^2.2",
"guzzlehttp/guzzle": "^7.8",
"league/climate": "^3.8.2"
"guzzlehttp/guzzle": "^7.9.2",
"league/climate": "^3.10.0"
},
"autoload": {
"psr-4": {
Expand Down
Loading
Loading