File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 1313use Icinga \Module \Director \Objects \IcingaHost ;
1414use Icinga \Module \Director \Objects \IcingaObject ;
1515use Icinga \Module \Director \Resolver \OverrideHelper ;
16+ use Icinga \Module \Director \Resolver \TemplateTree ;
1617use InvalidArgumentException ;
1718use RuntimeException ;
1819
@@ -139,6 +140,21 @@ protected function handleApiRequest()
139140 ], $ data );
140141 $ object ->replaceWith (IcingaObject::createByType ($ type , $ data , $ db ));
141142 }
143+
144+ if (in_array ((int ) $ object ->get ('id ' ), $ object ->listAncestorIds ())) {
145+ throw new RuntimeException (
146+ 'Import loop detected for the object '
147+ . $ object ->getObjectName () . ' -> Imports: '
148+ . implode (', ' , $ object ->getImports ())
149+ );
150+ }
151+
152+ if (in_array ($ object ->get ('object_name ' ), $ data ['imports ' ])) {
153+ throw new RuntimeException (
154+ 'You can not import the same object into itself: ' . $ object ->getObjectName ()
155+ );
156+ }
157+
142158 $ this ->persistChanges ($ object );
143159 $ this ->sendJson ($ object ->toPlainObject (false , true ));
144160 } elseif ($ allowsOverrides && $ type === 'service ' ) {
You can’t perform that action at this time.
0 commit comments