Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TestSonarDisableGraphQLIntrospection(SonarIntegrationTest):
codemod = SonarDisableGraphQLIntrospection
code_path = "tests/samples/disable_graphql_introspection.py"
expected_new_code = """\
from graphql_server.flask import GraphQLView
from graphql_server.flask.views import GraphQLView
from flask import Flask
from graphql import (
GraphQLSchema, GraphQLObjectType, GraphQLField, GraphQLString)
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/test_disable_graphql_introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class TestDisableGraphQLIntrospection(BaseIntegrationTest):
codemod = DisableGraphQLIntrospection
original_code = """
from graphql_server.flask import GraphQLView
from graphql_server.flask.views import GraphQLView
from flask import Flask
from graphql import (
GraphQLSchema, GraphQLObjectType, GraphQLField, GraphQLString)
Expand All @@ -32,7 +32,7 @@ class TestDisableGraphQLIntrospection(BaseIntegrationTest):
)
"""
expected_new_code = """
from graphql_server.flask import GraphQLView
from graphql_server.flask.views import GraphQLView
from flask import Flask
from graphql import (
GraphQLSchema, GraphQLObjectType, GraphQLField, GraphQLString)
Expand Down
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ get-hashes = 'codemodder.scripts.get_hashes:main'

[project.optional-dependencies]
semgrep = [
"semgrep>=1.131,<1.132",
"semgrep>=1.134,<1.135",
]
test = [
"azure-ai-inference>=1.0.0b1,<2.0",
"coverage>=7.10,<7.11",
"coverage-threshold~=0.4",
"defusedxml==0.7.1",
"types-defusedxml==0.7.0.20250809",
"types-defusedxml==0.7.0.20250822",
"flask-wtf==1.2.2",
"types-WTForms==3.2.1.20250809",
"Flask<4",
"httpx~=0.27",
"Jinja2~=3.1.2",
"jsonschema~=4.25.0",
"lxml>=6.0.0,<6.1.0",
"openai>=1.99,<1.100",
"openai>=1.102,<1.103",
"mock==5.2.*",
"pre-commit<5",
"Pyjwt~=2.10.0",
Expand All @@ -84,16 +84,16 @@ test = [
"numpy ~= 2.3.0; python_version > '3.10'",
"flask_wtf~=1.2.0",
"fickling~=0.1.0,>=0.1.3",
"graphql-server~=3.0.0b7",
"graphql-server~=3.0.0b9",
"unidiff>=0.7.5",
"semgrep>=1.131,<1.132",
"semgrep>=1.134,<1.135",
]
complexity = [
"radon==6.0.*",
"xenon==0.9.*",
]
openai = [
"openai>=1.99,<1.100",
"openai>=1.102,<1.103",
]
azure = [
"azure-ai-inference>=1.0.0b1,<2.0",
Expand Down
2 changes: 2 additions & 0 deletions src/core_codemods/disable_graphql_introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class FindGraphQLViewsWithIntrospection(
supported_functions = {
"graphql_server.flask.GraphQLView",
"graphql_server.flask.GraphQLView.as_view",
"graphql_server.flask.views.GraphQLView",
"graphql_server.flask.views.GraphQLView.as_view",
"graphql_server.sanic.GraphQLView",
"graphql_server.aiohttp.GraphQLView",
"graphql_server.webob.GraphQLView",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Introspection is often enabled by default in GraphQL without authentication. Thi

Our changes look something like this:
```diff
from graphql_server.flask import GraphQLView
from graphql_server.flask.views import GraphQLView
from flask import Flask
from graphql import (
GraphQLSchema, GraphQLObjectType, GraphQLField, GraphQLString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_name(self):

def test_simple(self, tmpdir):
input_code = """
from graphql_server.flask import GraphQLView
from graphql_server.flask.views import GraphQLView
from flask import Flask
from .schemas import schema

Expand All @@ -29,7 +29,7 @@ def test_simple(self, tmpdir):
)
"""
expected = """
from graphql_server.flask import GraphQLView
from graphql_server.flask.views import GraphQLView
from flask import Flask
from .schemas import schema
from graphql.validation import NoSchemaIntrospectionCustomRule
Expand Down
20 changes: 10 additions & 10 deletions tests/codemods/test_disable_graphql_introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_name(self):

def test_simple_flask(self, tmpdir):
input_code = """
from graphql_server.flask import GraphQLView
from graphql_server.flask.views import GraphQLView
from flask import Flask
from .schemas import schema

Expand All @@ -26,7 +26,7 @@ def test_simple_flask(self, tmpdir):
)
"""
expected = """
from graphql_server.flask import GraphQLView
from graphql_server.flask.views import GraphQLView
from flask import Flask
from .schemas import schema
from graphql.validation import NoSchemaIntrospectionCustomRule
Expand Down Expand Up @@ -77,7 +77,7 @@ def test_simple_constructor(self, tmpdir, module):

def test_add_indirect(self, tmpdir):
input_code = """
from graphql_server.flask import GraphQLView
from graphql_server.flask.views import GraphQLView
from flask import Flask
from .schemas import schema

Expand All @@ -89,7 +89,7 @@ def test_add_indirect(self, tmpdir):
)
"""
expected = """
from graphql_server.flask import GraphQLView
from graphql_server.flask.views import GraphQLView
from flask import Flask
from .schemas import schema
from graphql.validation import NoSchemaIntrospectionCustomRule
Expand All @@ -105,7 +105,7 @@ def test_add_indirect(self, tmpdir):

def test_add_list_double_indirect(self, tmpdir):
input_code = """
from graphql_server.flask import GraphQLView
from graphql_server.flask.views import GraphQLView
from flask import Flask
from .schemas import schema

Expand All @@ -117,7 +117,7 @@ def test_add_list_double_indirect(self, tmpdir):
)
"""
expected = """
from graphql_server.flask import GraphQLView
from graphql_server.flask.views import GraphQLView
from flask import Flask
from .schemas import schema
from graphql.validation import NoSchemaIntrospectionCustomRule
Expand All @@ -133,7 +133,7 @@ def test_add_list_double_indirect(self, tmpdir):

def test_add_dict_indirect(self, tmpdir):
input_code = """
from graphql_server.flask import GraphQLView
from graphql_server.flask.views import GraphQLView
from flask import Flask
from .schemas import schema

Expand All @@ -146,7 +146,7 @@ def test_add_dict_indirect(self, tmpdir):
)
"""
expected = """
from graphql_server.flask import GraphQLView
from graphql_server.flask.views import GraphQLView
from flask import Flask
from .schemas import schema
from graphql.validation import NoSchemaIntrospectionCustomRule
Expand All @@ -163,7 +163,7 @@ def test_add_dict_indirect(self, tmpdir):

def test_has_validation_rule(self, tmpdir):
input_code = """
from graphql_server.flask import GraphQLView
from graphql_server.flask.views import GraphQLView
from flask import Flask
from .schemas import schema
from graphql.validation import NoSchemaIntrospectionCustomRule
Expand All @@ -178,7 +178,7 @@ def test_has_validation_rule(self, tmpdir):

def test_has_graphene_validation_rule(self, tmpdir):
input_code = """
from graphql_server.flask import GraphQLView
from graphql_server.flask.views import GraphQLView
from flask import Flask
from .schemas import schema
from graphene.validation import DisableIntrospection
Expand Down
2 changes: 1 addition & 1 deletion tests/samples/disable_graphql_introspection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from graphql_server.flask import GraphQLView
from graphql_server.flask.views import GraphQLView
from flask import Flask
from graphql import (
GraphQLSchema, GraphQLObjectType, GraphQLField, GraphQLString)
Expand Down
Loading