Skip to content

A free open source IT asset/license management system

Make sure to throw 400-series SCIMExceptions when SCIM clients send bad data

Brady Wetheringtonb6ce823cc2a0
diff --git a/app/Models/SnipeSCIMConfig.php b/app/Models/SnipeSCIMConfig.php
index 0aac09631b..0b5718ecd8 100644
--- a/app/Models/SnipeSCIMConfig.php
+++ b/app/Models/SnipeSCIMConfig.php
@@ -302,11 +302,11 @@ class SnipeSCIMConfig
// addresses[type eq "work"]
$matches = null;
if (!preg_match('/^.+\[type eq "([a-zA-Z]+)"](?:\.([a-zA-Z]+))?$/', (string)$path, $matches)) {
- throw new \Exception("Unknown path type '$path'");
+ throw new SCIMException("Unknown path type '$path'")->setCode(422);
}
$type = $matches[1];
if ($type != 'work') {
- throw new \Exception("Unknown object type '$type'");
+ throw new SCIMException("Unknown object type '$type'")->setCode(422);
}
$attribute = array_key_exists(2, $matches) ? $matches[2] : null;
if (array_key_exists($attribute, self::$addressmap)) {
@@ -315,7 +315,7 @@ class SnipeSCIMConfig
}
- throw new \Exception("path for update $path");
+ throw new SCIMException("Could not handle path for update $path")->setCode(422);
}
}