ruby: start restructuring rack

This commit is contained in:
Alex Ford
2023-05-22 09:32:40 +01:00
parent f8d2cbbe79
commit c3ab867595
5 changed files with 1416 additions and 76 deletions

View File

@@ -1,3 +1,4 @@
private import codeql.ruby.AST
private import codeql.ruby.frameworks.Rack
private import codeql.ruby.DataFlow
@@ -8,3 +9,9 @@ query predicate rackResponseStatusCodes(Rack::ResponseNode resp, string status)
then status = resp.getAStatusCode().toString()
else status = "<unknown>"
}
query predicate rackResponseContentTypes(Rack::ResponseNode resp, DataFlow::Node contentType) {
contentType = resp.getMimetypeOrContentTypeArg()
}
query predicate mimetypeCalls(Rack::MimetypeCall c, string mimetype) { mimetype = c.getMimeType() }

View File

@@ -4,7 +4,8 @@ class HelloWorld
if something_goes_wrong(env)
status = 500
end
[status, {'Content-Type' => 'text/plain'}, ['Hello World']]
headers = {'Content-Type' => 'text/plain'}
[status, headers, ['Hello World']]
end
end
@@ -15,6 +16,7 @@ class Proxy
def call(the_env)
status, headers, body = @app.call(the_env)
headers.content_type = Rack::Mime.mime_type(".gz")
[status, headers, body]
end
end