mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Add concepts tests + some fixes
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
testFailures
|
||||
failures
|
||||
@@ -0,0 +1,2 @@
|
||||
import python
|
||||
import experimental.meta.ConceptsTest
|
||||
@@ -0,0 +1,9 @@
|
||||
from genshi.template.text import TextTemplate, NewTextTemplate, OldTextTemplate
|
||||
from genshi.template.markup import MarkupTemplate
|
||||
|
||||
def test():
|
||||
a = TextTemplate("abc") # $ templateConstruction="abc"
|
||||
a = OldTextTemplate("abc") # $ templateConstruction="abc"
|
||||
a = NewTextTemplate("abc") # $ templateConstruction="abc"
|
||||
a = MarkupTemplate("abc") # $ templateConstruction="abc"
|
||||
return a
|
||||
@@ -0,0 +1,2 @@
|
||||
testFailures
|
||||
failures
|
||||
@@ -0,0 +1,2 @@
|
||||
import python
|
||||
import experimental.meta.ConceptsTest
|
||||
@@ -0,0 +1,4 @@
|
||||
from mako.template import Template
|
||||
|
||||
def test():
|
||||
return Template("abc") # $ templateConstruction="abc"
|
||||
@@ -0,0 +1,2 @@
|
||||
testFailures
|
||||
failures
|
||||
@@ -0,0 +1,2 @@
|
||||
import python
|
||||
import experimental.meta.ConceptsTest
|
||||
@@ -0,0 +1,4 @@
|
||||
from trender import TRender
|
||||
|
||||
def test():
|
||||
return TRender("abc") # $ templateConstruction="abc"
|
||||
@@ -0,0 +1,2 @@
|
||||
testFailures
|
||||
failures
|
||||
@@ -0,0 +1,2 @@
|
||||
import python
|
||||
import experimental.meta.ConceptsTest
|
||||
@@ -0,0 +1,4 @@
|
||||
from airspeed import Template
|
||||
|
||||
def test():
|
||||
return Template("abc") # $ templateConstruction="abc"
|
||||
@@ -0,0 +1,9 @@
|
||||
import bottle
|
||||
from bottle import response, request, template, SimpleTemplate
|
||||
|
||||
app = bottle.app()
|
||||
@app.route('/test', method=['OPTIONS', 'GET']) # $ routeSetup="/test"
|
||||
def test1(): # $ requestHandler
|
||||
template("abc") # $ templateConstruction="abc"
|
||||
SimpleTemplate("abc") # $ templateConstruction="abc"
|
||||
return '[1]' # $ HttpResponse mimetype=text/html responseBody='[1]'
|
||||
@@ -0,0 +1,2 @@
|
||||
testFailures
|
||||
failures
|
||||
@@ -0,0 +1,2 @@
|
||||
import python
|
||||
import experimental.meta.ConceptsTest
|
||||
@@ -0,0 +1,4 @@
|
||||
from chameleon import PageTemplate
|
||||
|
||||
def test():
|
||||
return PageTemplate("abc") # $ templateConstruction="abc"
|
||||
@@ -0,0 +1,2 @@
|
||||
testFailures
|
||||
failures
|
||||
@@ -0,0 +1,2 @@
|
||||
import python
|
||||
import experimental.meta.ConceptsTest
|
||||
@@ -0,0 +1,4 @@
|
||||
from chevron import render
|
||||
|
||||
def test():
|
||||
return render("abc") # $ templateConstruction="abc"
|
||||
@@ -0,0 +1,17 @@
|
||||
from django.template import Template, engines
|
||||
from django.urls import path
|
||||
from django.http.response import HttpResponse,
|
||||
|
||||
def a(request): # $requestHandler
|
||||
t = Template("abc").render() # $templateConstruction="abc"
|
||||
return HttpResponse(t) # $HttpResponse
|
||||
|
||||
def b(request): # $requestHandler
|
||||
# This case is not yet supported
|
||||
t = django.template.engines["django"].from_string("abc") # $MISSING:templateConstruction="abc"
|
||||
return HttpResponse(t) # $HttpResponse
|
||||
|
||||
urlpatterns = [
|
||||
path("a", a), # $ routeSetup="a"
|
||||
path("b", b), # $ routeSetup="b"
|
||||
]
|
||||
@@ -222,25 +222,25 @@ def test_taint(name = "World!", number="0", foo="foo"): # $requestHandler route
|
||||
# render_template_string
|
||||
source = TAINTED_STRING
|
||||
ensure_tainted(source) # $ tainted
|
||||
res = render_template_string(source)
|
||||
res = render_template_string(source) # $ templateConstruction=source
|
||||
ensure_tainted(res) # $ tainted
|
||||
|
||||
# since template variables are auto-escaped, we don't treat result as tainted
|
||||
# see https://flask.palletsprojects.com/en/2.3.x/api/#flask.render_template_string
|
||||
res = render_template_string("Hello {{ foo }}", foo=TAINTED_STRING)
|
||||
res = render_template_string("Hello {{ foo }}", foo=TAINTED_STRING) # $ templateConstruction="Hello {{ foo }}"
|
||||
ensure_not_tainted(res)
|
||||
|
||||
|
||||
# stream_template_string
|
||||
source = TAINTED_STRING
|
||||
ensure_tainted(source) # $ tainted
|
||||
res = stream_template_string(source)
|
||||
res = stream_template_string(source) # $ templateConstruction=source
|
||||
for x in res:
|
||||
ensure_tainted(x) # $ tainted
|
||||
|
||||
# since template variables are auto-escaped, we don't treat result as tainted
|
||||
# see https://flask.palletsprojects.com/en/2.3.x/api/#flask.stream_template_string
|
||||
res = stream_template_string("Hello {{ foo }}", foo=TAINTED_STRING)
|
||||
res = stream_template_string("Hello {{ foo }}", foo=TAINTED_STRING) # $ templateConstruction="Hello {{ foo }}"
|
||||
for x in res:
|
||||
ensure_not_tainted(x)
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
from flask import Flask, Response, stream_with_context, render_template_string, stream_template_string
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route("/a") # $routeSetup="/a"
|
||||
def a(): # $requestHandler
|
||||
r = render_template_string("abc") # $ templateConstruction="abc"
|
||||
return r # $ HttpResponse
|
||||
|
||||
@app.route("/b") # $routeSetup="/b"
|
||||
def b(): # $requestHandler
|
||||
s = stream_template_string("abc") # $ templateConstruction="abc"
|
||||
r = Response(stream_with_context(s)) # $ HttpResponse
|
||||
return r # $ HttpResponse
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True)
|
||||
@@ -0,0 +1,2 @@
|
||||
testFailures
|
||||
failures
|
||||
@@ -0,0 +1,2 @@
|
||||
import python
|
||||
import experimental.meta.ConceptsTest
|
||||
@@ -0,0 +1,7 @@
|
||||
from jinja2 import Environment, Template
|
||||
|
||||
def test():
|
||||
env = Environment()
|
||||
t = env.from_string("abc") # $ templateConstruction="abc"
|
||||
t = Template("abc") # $ templateConstruction="abc"
|
||||
return t
|
||||
Reference in New Issue
Block a user