@@ -299,4 +299,51 @@ private module RestFramework {
299299 override string getMimetypeDefault ( ) { none ( ) }
300300 }
301301 }
302+
303+ // ---------------------------------------------------------------------------
304+ // Exception response modeling
305+ // ---------------------------------------------------------------------------
306+ /**
307+ * Provides models for the `rest_framework.exceptions.APIException` class and subclasses
308+ *
309+ * See https://www.django-rest-framework.org/api-guide/exceptions/#api-reference
310+ */
311+ module APIException {
312+ /** A direct instantiation of `rest_framework.exceptions.APIException` or subclass. */
313+ private class ClassInstantiation extends HTTP:: Server:: HttpResponse:: Range ,
314+ DataFlow:: CallCfgNode {
315+ string className ;
316+
317+ ClassInstantiation ( ) {
318+ className in [
319+ "APIException" , "ValidationError" , "ParseError" , "AuthenticationFailed" ,
320+ "NotAuthenticated" , "PermissionDenied" , "NotFound" , "MethodNotAllowed" , "NotAcceptable" ,
321+ "UnsupportedMediaType" , "Throttled"
322+ ] and
323+ this =
324+ API:: moduleImport ( "rest_framework" )
325+ .getMember ( "exceptions" )
326+ .getMember ( className )
327+ .getACall ( )
328+ }
329+
330+ override DataFlow:: Node getBody ( ) {
331+ className in [
332+ "APIException" , "ValidationError" , "ParseError" , "AuthenticationFailed" ,
333+ "NotAuthenticated" , "PermissionDenied" , "NotFound" , "NotAcceptable"
334+ ] and
335+ result = this .getArg ( 0 )
336+ or
337+ className in [ "MethodNotAllowed" , "UnsupportedMediaType" , "Throttled" ] and
338+ result = this .getArg ( 1 )
339+ or
340+ result = this .getArgByName ( "detail" )
341+ }
342+
343+ // How to support the `headers` argument here?
344+ override DataFlow:: Node getMimetypeOrContentTypeArg ( ) { none ( ) }
345+
346+ override string getMimetypeDefault ( ) { none ( ) }
347+ }
348+ }
302349}
0 commit comments