summaryrefslogtreecommitdiffstats
path: root/lib/private/Repair
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2017-07-20 22:48:13 +0200
committerLukas Reschke <lukas@statuscode.ch>2017-07-20 22:48:13 +0200
commit3d2600b0399af0dd4521469725f5e4bdf348bd2e (patch)
treeb231906605d82e7fe537a81a9e10299ca9beb37f /lib/private/Repair
parent4826fd701dda218792b5072977b24da7d42a94fa (diff)
downloadnextcloud-server-3d2600b0399af0dd4521469725f5e4bdf348bd2e.tar.gz
nextcloud-server-3d2600b0399af0dd4521469725f5e4bdf348bd2e.zip
Add Phan plugin to check for SQL injections
This adds a phan plugin which checks for SQL injections on code using our QueryBuilder, while it isn't perfect it should already catch most potential issues. As always, static analysis will sometimes have false positives and this is also here the case. So in some cases the analyzer just doesn't know if something is potential user input or not, thus I had to add some `@suppress SqlInjectionChecker` in front of those potential injections. The Phan plugin hasn't the most awesome code but it works and I also added a file with test cases. Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'lib/private/Repair')
-rw-r--r--lib/private/Repair/CleanTags.php1
-rw-r--r--lib/private/Repair/NC13/RepairInvalidPaths.php9
-rw-r--r--lib/private/Repair/OldGroupMembershipShares.php1
-rw-r--r--lib/private/Repair/RepairInvalidShares.php1
4 files changed, 12 insertions, 0 deletions
diff --git a/lib/private/Repair/CleanTags.php b/lib/private/Repair/CleanTags.php
index 9b44fb1e671..d3bea0f9957 100644
--- a/lib/private/Repair/CleanTags.php
+++ b/lib/private/Repair/CleanTags.php
@@ -167,6 +167,7 @@ class CleanTags implements IRepairStep {
* @param string $sourceId
* @param string $sourceNullColumn If this column is null in the source table,
* the entry is deleted in the $deleteTable
+ * @suppress SqlInjectionChecker
*/
protected function deleteOrphanEntries(IOutput $output, $repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn) {
$qb = $this->connection->getQueryBuilder();
diff --git a/lib/private/Repair/NC13/RepairInvalidPaths.php b/lib/private/Repair/NC13/RepairInvalidPaths.php
index efc682bf44f..cbbbc82801c 100644
--- a/lib/private/Repair/NC13/RepairInvalidPaths.php
+++ b/lib/private/Repair/NC13/RepairInvalidPaths.php
@@ -51,6 +51,10 @@ class RepairInvalidPaths implements IRepairStep {
return 'Repair invalid paths in file cache';
}
+ /**
+ * @return \Generator
+ * @suppress SqlInjectionChecker
+ */
private function getInvalidEntries() {
$builder = $this->connection->getQueryBuilder();
@@ -95,6 +99,11 @@ class RepairInvalidPaths implements IRepairStep {
return $this->getIdQuery->execute()->fetchColumn();
}
+ /**
+ * @param string $fileid
+ * @param string $newPath
+ * @suppress SqlInjectionChecker
+ */
private function update($fileid, $newPath) {
if (!$this->updateQuery) {
$builder = $this->connection->getQueryBuilder();
diff --git a/lib/private/Repair/OldGroupMembershipShares.php b/lib/private/Repair/OldGroupMembershipShares.php
index ea0256f64b8..5b941d1fcbd 100644
--- a/lib/private/Repair/OldGroupMembershipShares.php
+++ b/lib/private/Repair/OldGroupMembershipShares.php
@@ -65,6 +65,7 @@ class OldGroupMembershipShares implements IRepairStep {
* Must throw exception on error.
*
* @throws \Exception in case of failure
+ * @suppress SqlInjectionChecker
*/
public function run(IOutput $output) {
$deletedEntries = 0;
diff --git a/lib/private/Repair/RepairInvalidShares.php b/lib/private/Repair/RepairInvalidShares.php
index 78884ca9cde..92423165541 100644
--- a/lib/private/Repair/RepairInvalidShares.php
+++ b/lib/private/Repair/RepairInvalidShares.php
@@ -56,6 +56,7 @@ class RepairInvalidShares implements IRepairStep {
/**
* Adjust file share permissions
+ * @suppress SqlInjectionChecker
*/
private function adjustFileSharePermissions(IOutput $out) {
$mask = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE;