Skip to content

Commit e95e9f3

Browse files
committed
Improve validation of RPCs that contain passwords
Signed-off-by: Volker Theile <votdev@gmx.de>
1 parent 2ce41f7 commit e95e9f3

10 files changed

Lines changed: 36 additions & 0 deletions

File tree

‎deb/openmediavault/debian/changelog‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ openmediavault (7.7.6-1) stable; urgency=medium
33
* Add search field to the `Diagnostics | System Logs | Logs` page.
44
* Display more information about the last/current scrub run on the
55
BTRFS details page.
6+
* Improve validation of RPCs that contain passwords.
67

78
-- Volker Theile <volker.theile@openmediavault.org> Fri, 25 Apr 2025 10:22:31 +0200
89

‎deb/openmediavault/usr/share/openmediavault/datamodels/rpc.certificatemgmt.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@
147147
},
148148
"password": {
149149
"type": "string",
150+
"format": "no-multi-line",
150151
"required": true
151152
}
152153
}

‎deb/openmediavault/usr/share/openmediavault/datamodels/rpc.emailnotification.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
},
5050
"password": {
5151
"type": "string",
52+
"format": "no-multi-line",
5253
"required": true
5354
},
5455
"primaryemail": {

‎deb/openmediavault/usr/share/openmediavault/datamodels/rpc.network.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@
633633
},
634634
"httppassword": {
635635
"type": "string",
636+
"format": "no-multi-line",
636637
"required": true
637638
},
638639
"httpsenable": {
@@ -655,6 +656,7 @@
655656
},
656657
"httpspassword": {
657658
"type": "string",
659+
"format": "no-multi-line",
658660
"required": true
659661
},
660662
"ftpenable": {
@@ -677,6 +679,7 @@
677679
},
678680
"ftppassword": {
679681
"type": "string",
682+
"format": "no-multi-line",
680683
"required": true
681684
}
682685
}

‎deb/openmediavault/usr/share/openmediavault/datamodels/rpc.rsync.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@
206206
},
207207
"password": {
208208
"type": "string",
209+
"format": "no-multi-line",
209210
"required": true
210211
},
211212
"sshcertificateref": {

‎deb/openmediavault/usr/share/openmediavault/datamodels/rpc.rsyncd.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
},
101101
"password": {
102102
"type": "string",
103+
"format": "no-multi-line",
103104
"required": true
104105
}
105106
}

‎deb/openmediavault/usr/share/openmediavault/datamodels/rpc.session.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"password": {
1212
"type": "string",
13+
"format": "no-multi-line",
1314
"required": true
1415
}
1516
}

‎deb/openmediavault/usr/share/openmediavault/datamodels/rpc.usermgmt.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"password": {
1212
"type": "string",
13+
"format": "no-multi-line",
1314
"required": true
1415
}
1516
}
@@ -54,6 +55,7 @@
5455
},
5556
"password": {
5657
"type": "string",
58+
"format": "no-multi-line",
5759
"required": true
5860
},
5961
"email": {
@@ -99,6 +101,7 @@
99101
"properties": {
100102
"password": {
101103
"type": "string",
104+
"format": "no-multi-line",
102105
"required": false
103106
},
104107
"email": {
@@ -236,6 +239,7 @@
236239
"properties": {
237240
"password":{
238241
"type": "string",
242+
"format": "no-multi-line",
239243
"required": true
240244
}
241245
}

‎deb/openmediavault/usr/share/openmediavault/unittests/php/test_openmediavault_datamodel_schema.php‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,20 @@ public function testCheckFormatNetbios4() {
156156
$schema->checkFormat("FOO]BAR",
157157
[ "format" => "netbiosname" ], "field1");
158158
}
159+
160+
/**
161+
* @doesNotPerformAssertions
162+
*/
163+
public function testCheckFormatNoMultiLine1() {
164+
$schema = $this->getSchema();
165+
$schema->checkFormat("foo123",
166+
[ "format" => "no-multi-line" ], "field1");
167+
}
168+
169+
public function testCheckFormatNoMultiLine2() {
170+
$schema = $this->getSchema();
171+
$this->expectException(\OMV\Json\SchemaValidationException::class);
172+
$schema->checkFormat("foo\r\nbar",
173+
[ "format" => "no-multi-line" ], "field1");
174+
}
159175
}

‎deb/openmediavault/usr/share/php/openmediavault/datamodel/schema.inc‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ class Schema extends \OMV\Json\Schema {
149149
$name, $value);
150150
}
151151
break;
152+
case "no-multi-line":
153+
if (!preg_match('/^[^\r\n]*$/', $value)) {
154+
throw new \OMV\Json\SchemaValidationException(
155+
"%s: The value contains a multi-line content.",
156+
$name);
157+
}
158+
break;
152159
default:
153160
throw new \OMV\Json\SchemaException(
154161
"%s: The format '%s' is not defined.",

0 commit comments

Comments
 (0)