mirror of https://github.com/google/oss-fuzz.git
jpeg-js: Initial integration (#10636)
Integrating jpeg-js into OSS-Fuzz.
This commit is contained in:
parent
95b2e0d430
commit
310ee92edd
|
@ -0,0 +1,26 @@
|
|||
# Copyright 2023 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
FROM gcr.io/oss-fuzz-base/base-builder-javascript
|
||||
|
||||
COPY build.sh $SRC/
|
||||
|
||||
RUN git clone --depth 1 https://github.com/jpeg-js/jpeg-js
|
||||
|
||||
COPY fuzz_encode.js $SRC/jpeg-js
|
||||
COPY fuzz_decode.js $SRC/jpeg-js
|
||||
|
||||
WORKDIR $SRC/jpeg-js
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
# Copyright 2023 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
npm install --save-dev @jazzer.js/core
|
||||
npm i
|
||||
|
||||
# Build Fuzzers.
|
||||
compile_javascript_fuzzer jpeg-js fuzz_encode.js -i jpeg-js --sync
|
||||
compile_javascript_fuzzer jpeg-js fuzz_decode.js -i jpeg-js --sync
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright 2023 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const { FuzzedDataProvider } = require('@jazzer.js/core');
|
||||
const jpeg = require("./index");
|
||||
|
||||
module.exports.fuzz = function (data) {
|
||||
const provider = new FuzzedDataProvider(data);
|
||||
|
||||
try {
|
||||
jpeg.decode(provider.consumeBytes(provider.consumeIntegralInRange(0, 2**48-1)),
|
||||
{useTArray: provider.consumeBoolean(),
|
||||
colorTransform: provider.consumeBoolean(),
|
||||
formatAsRGBA: provider.consumeBoolean(),
|
||||
tolerantDecoding: provider.consumeBoolean()}
|
||||
);
|
||||
} catch (error) {
|
||||
// Catch all errors to find more critical bugs.
|
||||
}
|
||||
};
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright 2023 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const { FuzzedDataProvider } = require('@jazzer.js/core');
|
||||
const jpeg = require("./index");
|
||||
|
||||
module.exports.fuzz = function (data) {
|
||||
const provider = new FuzzedDataProvider(data);
|
||||
|
||||
var width = provider.consumeIntegralInRange(0, 2**48-1),
|
||||
height = provider.consumeIntegralInRange(0, 2**48-1),
|
||||
quality = provider.consumeIntegralInRange(0, 2**48-1);
|
||||
var frameData = provider.consumeRemainingAsBytes();
|
||||
var rawImageData = {
|
||||
data: frameData,
|
||||
width: width,
|
||||
height: height,
|
||||
};
|
||||
|
||||
try {
|
||||
var jpegImageData = jpeg.encode(rawImageData, quality);
|
||||
} catch (error) {
|
||||
// Catch all errors to find critical bugs.
|
||||
}
|
||||
};
|
|
@ -0,0 +1,14 @@
|
|||
homepage: https://github.com/jpeg-js/jpeg-js
|
||||
language: javascript
|
||||
main_repo: https://github.com/jpeg-js/jpeg-js
|
||||
fuzzing_engines:
|
||||
- libfuzzer
|
||||
sanitizers:
|
||||
- none
|
||||
vendor_ccs:
|
||||
- "wagner@code-intelligence.com"
|
||||
- "yakdan@code-intelligence.com"
|
||||
- "patrice.salathe@code-intelligence.com"
|
||||
- "hlin@code-intelligence.com"
|
||||
- "christopher.krah@code-intelligence.com"
|
||||
- "bug-disclosure@code-intelligence.com"
|
Loading…
Reference in New Issue