Skip to content

Commit 1b3841f

Browse files
authored
update file-type dependency to address CVE (#195)
* security: upgrade file-type dependency for cve https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-36313 * bump patch version to 4.2.6; add changelog entry * [ci] bump actions versions to silence warnings; add node 20 to the matrix * [ci] bump coveralls action version to silence node 16 warning
1 parent 47486e1 commit 1b3841f

File tree

6 files changed

+166
-27
lines changed

6 files changed

+166
-27
lines changed

.github/workflows/gh-pages-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: GH Pages Deploy
22

33
on:
4-
workflow_dispatch:
4+
workflow_dispatch:
55
push:
66
branches:
77
- master

.github/workflows/run-tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ jobs:
99

1010
strategy:
1111
matrix:
12-
node-version: [14.x, 16.x, 18.x]
12+
node-version: [14.x, 16.x, 18.x, 20.x]
1313

1414
steps:
15-
- uses: actions/checkout@v1
15+
- uses: actions/checkout@v4
1616
- name: Use Node.js ${{ matrix.node-version }}
17-
uses: actions/setup-node@v1
17+
uses: actions/setup-node@v4
1818
with:
1919
node-version: ${{ matrix.node-version }}
2020
- name: npm install, build, and test
@@ -29,8 +29,8 @@ jobs:
2929
JOB_CONTEXT: ${{ toJson(matrix) }}
3030
run: echo "$JOB_CONTEXT"
3131
- name: Coveralls
32-
if: matrix.node-version == '14.x'
33-
uses: coverallsapp/github-action@master
32+
if: matrix.node-version == '20.x'
33+
uses: coverallsapp/github-action@v2
3434
with:
3535
github-token: ${{ secrets.GITHUB_TOKEN }}
3636
path-to-lcov: ./docs/coverage/lcov.info

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
### Changelog
22

3+
##### 4.2.6
4+
5+
- Upgrade the [`file-type`](https://www.npmjs.com/package/file-type) dependency to address [CVE-2022-36313](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-36313).
6+
37
##### 4.2.5
48

59
- Fix a bug that set `undefined` on sql.js prepared statement values causing sql.js to throw an error.

lib/tiles/creator/tileCreator.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fileType from 'file-type';
1+
import * as fileType from 'file-type';
22
import proj4 from 'proj4';
33
import ProjectTile from './projectTile';
44

@@ -138,12 +138,12 @@ export class TileCreator {
138138

139139
/**
140140
* Adds a tile and reprojects it if necessary before drawing it into the target canvas
141-
* @param tileData
142-
* @param gridColumn
143-
* @param gridRow
141+
* @param tileData a `string` file path or `Buffer` containing image data
142+
* @param gridColumn `number`
143+
* @param gridRow `number`
144144
*/
145145
async addTile(tileData: any, gridColumn: number, gridRow: number): Promise<void> {
146-
const type = fileType(tileData);
146+
const type = await (typeof tileData === 'string' ? fileType.fromFile(tileData) : fileType.fromBuffer(tileData));
147147
const tile = await ImageUtils.getImage(tileData, type.mime);
148148
this.tileContext.clearRect(0, 0, this.tileMatrix.tile_width, this.tileMatrix.tile_height);
149149
this.tileContext.drawImage(tile.image, 0, 0);

package-lock.json

Lines changed: 149 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ngageoint/geopackage",
3-
"version": "4.2.5",
3+
"version": "4.2.6",
44
"description": "GeoPackage JavaScript Library",
55
"keywords": [
66
"NGA",
@@ -38,7 +38,7 @@
3838
"@turf/polygon-to-line": "6.5.0",
3939
"@types/geojson": "7946.0.8",
4040
"@types/proj4": "2.5.2",
41-
"file-type": "12.4.0",
41+
"file-type": "^16.5.4",
4242
"image-size": "0.8.3",
4343
"lodash": "4.17.21",
4444
"proj4": "2.8.0",

0 commit comments

Comments
 (0)