Skip to content

Commit

Permalink
Merge branch 'release/2.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
w00fz committed Jun 3, 2021
2 parents 4fb7d0d + 15ea3b7 commit a8745c0
Show file tree
Hide file tree
Showing 11 changed files with 447 additions and 295 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v2.3.2
## 06/03/2021

1. [](#bugfix)
* Better validation for Git Repository value on both Wizard and Backend.
* Prevent malicious commands from being executed in Wizard when "Verifying Authentication, Connection and Branch".

# v2.3.1
## 04/30/2021

Expand Down
10 changes: 9 additions & 1 deletion app/wizard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { config } from 'grav-config';
import $ from 'jquery';
import 'whatwg-fetch';

const GIT_REGEX = /(?:git|ssh|https?|git@[-\w.]+):(\/\/)?(.*?)(\.git)(\/?|\#[-\d\w._]+?)$/;
const WIZARD = $('[data-remodal-id="wizard"]');
const RESET_LOCAL = $('[data-remodal-id="reset-local"]');
const SERVICES = { 'github': 'github.com', 'bitbucket': 'bitbucket.org', 'gitlab': 'gitlab.com', 'allothers': 'allothers.repo' };
Expand Down Expand Up @@ -252,9 +253,16 @@ $(document).on('change', '[name="gitsync[repository]"]', () => {
$(document).on('input', '[name="gitsync[repo_url]"]', (event) => {
const target = $(event.currentTarget);
const value = target.val();
const isGitURL = GIT_REGEX.test(value);
const next = WIZARD.find('[data-gitsync-action="next"]');

if (value.length) {
target.removeClass('invalid');

if (!isGitURL) {
target.addClass('invalid');
}

if (isGitURL && value.length) {
enableButton(next);
} else {
disableButton(next);
Expand Down
4 changes: 2 additions & 2 deletions blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Git Sync
type: plugin
slug: git-sync
version: 2.3.1
version: 2.3.2
description: Allows to synchronize portions of Grav with Git Repositories (GitHub, BitBucket, GitLab)
icon: git
author:
Expand Down Expand Up @@ -62,7 +62,7 @@ form:
underline: true

SyncNotice:
type: spacer
type: hidden
markdown: true
text: |
! To improve the speed of saving pages you can disable automatic sync. Then, changes to a page will not be sent to the remote repository on every save. To sync your changes to the repository tap the GitSync button (<i class="fa fa-git"></i>) in the top left of the Administration Panel, or use the below Scheduler option to add the GitSync Syncronization Job to the Scheduler (<strong>Grav 1.6 required</strong>).
Expand Down
5 changes: 5 additions & 0 deletions classes/GitSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Grav\Common\Grav;
use Grav\Common\Plugin;
use Grav\Common\Utils;
use http\Exception\RuntimeException;
use RocketTheme\Toolbox\File\File;
use SebastianBergmann\Git\Git;

Expand Down Expand Up @@ -115,6 +116,10 @@ public function getRuntimeInformation()
*/
public function testRepository($url, $branch)
{
if (!preg_match(Helper::GIT_REGEX, $url)) {
throw new \RuntimeException("Git Repository value does not match the supported format.");
}

$branch = $branch ? '"' . $branch . '"' : '';
return $this->execute("ls-remote \"{$url}\" {$branch}");
}
Expand Down
3 changes: 3 additions & 0 deletions classes/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class Helper
/** @var string */
private static $hash = '594ef69d-6c29-45f7-893a-f1b4342687d3';

/** @var string */
const GIT_REGEX = '/(?:git|ssh|https?|git@[-\w.]+):(\/\/)?(.*?)(\.git)(\/?|\#[-\d\w._]+?)$/';

/**
* Checks if the user/ folder is already initialized
*
Expand Down
6 changes: 5 additions & 1 deletion css-compiled/git-sync.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions js/app.js

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@
},
"homepage": "https://github.com/trilbymedia/grav-plugin-git-sync#readme",
"devDependencies": {
"@babel/core": "^7.13.15",
"@babel/core": "^7.14.3",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/plugin-proposal-json-strings": "^7.13.8",
"@babel/plugin-proposal-object-rest-spread": "^7.13.8",
"@babel/plugin-proposal-json-strings": "^7.14.2",
"@babel/plugin-proposal-object-rest-spread": "^7.14.4",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-import-meta": "^7.10.4",
"@babel/polyfill": "^7.11.5",
"@babel/preset-env": "^7.13.15",
"@babel/polyfill": "^7.12.1",
"@babel/preset-env": "^7.14.4",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.2",
"css-loader": "^5.2.2",
"eslint": "^7.24.0",
"css-loader": "^5.2.6",
"eslint": "^7.27.0",
"eslint-loader": "^4.0.2",
"exports-loader": "^2.0.0",
"imports-loader": "^2.0.0",
"exports-loader": "^3.0.0",
"imports-loader": "^3.0.0",
"json-loader": "^0.5.7",
"style-loader": "^2.0.0",
"uglifyjs-webpack-plugin": "^2.2.0",
"webpack": "^5.33.2",
"webpack-cli": "^4.6.0",
"webpack": "^5.38.1",
"webpack-cli": "^4.7.0",
"whatwg-fetch": "^3.6.2"
}
}
5 changes: 5 additions & 0 deletions scss/plugin/_wizard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
border-color: #ddd;
}

input.invalid {
border-color: #f4516d;
color: #f4516d;
}

label {
&.disabled {
color: #ccc;
Expand Down
4 changes: 2 additions & 2 deletions templates/partials/modal-wizard.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
</li>
<li>Once you have made your repository, copy the full HTTPS URL and paste it into the box below.
<ul>
<li>Most services offer both SSH and HTTPS addresses, <strong>but only HTTPS is supported at this time</strong>.</li>
<li>Most services offer both SSH and HTTPS addresses, <strong>HTTPS is the recommended method.</strong>.</li>
</ul>
</li>
</ol>
Expand Down Expand Up @@ -202,7 +202,7 @@

<p>
<label>
Git Repository (<strong>HTTPS only</strong>)
Git Repository

<input type="text" name="gitsync[repo_url]" placeholder="https://github.com/getgrav/grav.git" value="{{ settings.repository|default('') }}" />
</label>
Expand Down
Loading

0 comments on commit a8745c0

Please sign in to comment.