8000 Merge pull request #23812 from tacaswell/ci_add_codeql · matplotlib/matplotlib@8f0003a · GitHub
[go: up one dir, main page]

Skip to content

Commit 8f0003a

Browse files
authored
Merge pull request #23812 from tacaswell/ci_add_codeql
Ci add codeql
2 parents 9b7c902 + 340eee2 commit 8f0003a

File tree

6 files changed

+76
-6
lines changed

6 files changed

+76
-6
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
name: "CodeQL"
3+
4+
on:
5+
push:
6+
branches: [main, v*.x]
7+
pull_request:
8+
# The branches below must be a subset of the branches above
9+
branches: [main]
10+
schedule:
11+
- cron: '45 19 * * 1'
12+
13+
jobs:
14+
analyze:
15+
name: Analyze
16+
runs-on: ubuntu-latest
17+
permissions:
18+
actions: read
19+
contents: read
20+
security-events: write
21+
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
language: ['cpp', 'javascript', 'python']
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v3
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v4
33+
if: matrix.language != 'javascript'
34+
with:
35+
python-version: '3.x'
36+
- name: Install dependencies
37+
if: matrix.language != 'javascript'
38+
run: |
39+
python -m pip install --upgrade pip setuptools wheel
40+
# TODO: Use pip-tools instead when it supports build-system
41+
# dependencies so we don't need another copy here.
42+
# https://github.com/jazzband/pip-tools/pull/1681
43+
python -m pip install --upgrade \
44+
certifi contourpy cycler fonttools kiwisolver importlib_resources \
45+
numpy packaging pillow pyparsing python-dateutil setuptools-scm
46+
echo "CODEQL_PYTHON=$(which python)" >> $GITHUB_ENV
47+
48+
- name: Initialize CodeQL
49+
uses: github/codeql-action/init@v2
50+
with:
51+
languages: ${{ matrix.language }}
52+
setup-python-dependencies: false
53+
54+
- name: Build compiled code
55+
if: matrix.language == 'cpp'
56+
run: |
57+
mkdir ~/.cache/matplotlib
58+
$CODEQL_PYTHON setup.py build
59+
60+
- name: Perform CodeQL Analysis
61+
uses: github/codeql-action/analyze@v2

setupext.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ def get_and_extract_tarball(urls, sha, dirname):
118118
"""
119119
toplevel = Path("build", dirname)
120120
if not toplevel.exists(): # Download it or load it from cache.
121+
try:
122+
import certifi # noqa
123+
except ImportError as e:
124+
raise ImportError(
125+
f"`certifi` is unavailable ({e}) so unable to download any of "
126+
f"the following: {urls}.") from None
127+
121128
Path("build").mkdir(exist_ok=True)
122129
for url in urls:
123130
try:

src/_backend_agg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ void BufferRegion::to_string_argb(uint8_t *buf)
1111
unsigned char tmp;
1212
size_t i, j;
1313

14-
memcpy(buf, data, height * stride);
14+
memcpy(buf, data, (size_t) height * stride);
1515

1616
for (i = 0; i < (size_t)height; ++i) {
1717
pix = buf + i * stride;

src/_backend_agg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ class QuadMeshGenerator
11241124

11251125
inline size_t num_paths() const
11261126
{
1127-
return m_meshWidth * m_meshHeight;
1127+
return (size_t) m_meshWidth * m_meshHeight;
11281128
}
11291129

11301130
inline path_iterator operator()(size_t i) const

src/_backend_agg_wrapper.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static PyObject *PyBufferRegion_to_string(PyBufferRegion *self, PyObject *args)
5353
return NULL;
5454
}
5555
return PyBytes_FromStringAndSize((const char *)self->x->get_data(),
56-
self->x->get_height() * self->x->get_stride());
56+
(Py_ssize_t) self->x->get_height() * self->x->get_stride());
5757
}
5858

5959
/* TODO: This doesn't seem to be used internally. Remove? */
@@ -98,8 +98,10 @@ static PyObject *PyBufferRegion_to_string_argb(PyBufferRegion *self, PyObject *a
< A92E code>9898
}
9999
PyObject *bufobj;
100100
uint8_t *buf;
101-
102-
bufobj = PyBytes_FromStringAndSize(NULL, self->x->get_height() * self->x->get_stride());
101+
Py_ssize_t height, stride;
102+
height = self->x->get_height();
103+
stride = self->x->get_stride();
104+
bufobj = PyBytes_FromStringAndSize(NULL, height * stride);
103105
buf = (uint8_t *)PyBytes_AS_STRING(bufobj);
104106

105107
CALL_CPP_CLEANUP("to_string_argb", (self->x->to_string_argb(buf)), Py_DECREF(bufobj));

src/_path.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ bool convert_to_string(PathIterator &path,
12221222
clipped_t clipped(nan_removed, do_clip, clip_rect);
12231223
simplify_t simplified(clipped, simplify, path.simplify_threshold());
12241224

1225-
buffersize = path.total_vertices() * (precision + 5) * 4;
1225+
buffersize = (size_t) path.total_vertices() * (precision + 5) * 4;
12261226
if (buffersize == 0) {
12271227
return true;
12281228
}

0 commit comments

Comments
 (0)
0