Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bdf26ae

Browse filesBrowse files
DavidKorczynskiBethGriggs
authored andcommitted
build: add build flag for OSS-Fuzz integration
Refs: google/oss-fuzz#3860 Fixes: #33724 PR-URL: #34761 Fixes: #33724 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 952f233 commit bdf26ae
Copy full SHA for bdf26ae

File tree

Expand file treeCollapse file tree

3 files changed

+52
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+52
-0
lines changed
Open diff view settings
Collapse file

‎configure.py‎

Copy file name to clipboardExpand all lines: configure.py
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,11 @@
392392
dest='v8_options',
393393
help='v8 options to pass, see `node --v8-options` for examples.')
394394

395+
parser.add_option('--with-ossfuzz',
396+
action='store_true',
397+
dest='ossfuzz',
398+
help='Enables building of fuzzers. This command should be run in an OSS-Fuzz Docker image.')
399+
395400
parser.add_option('--with-arm-float-abi',
396401
action='store',
397402
dest='arm_float_abi',
@@ -1770,6 +1775,9 @@ def make_bin_override():
17701775
configure_static(output)
17711776
configure_inspector(output)
17721777

1778+
# Forward OSS-Fuzz settings
1779+
output['variables']['ossfuzz'] = b(options.ossfuzz)
1780+
17731781
# variables should be a root level element,
17741782
# move everything else to target_defaults
17751783
variables = output['variables']
Collapse file

‎node.gyp‎

Copy file name to clipboardExpand all lines: node.gyp
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
'node_use_bundled_v8%': 'true',
1313
'node_shared%': 'false',
1414
'force_dynamic_crt%': 0,
15+
'ossfuzz' : 'false',
1516
'node_module_version%': '',
1617
'node_shared_brotli%': 'false',
1718
'node_shared_zlib%': 'false',
@@ -1125,6 +1126,38 @@
11251126
} ],
11261127
]
11271128
}, # specialize_node_d
1129+
{ # fuzz_url
1130+
'target_name': 'fuzz_url',
1131+
'type': 'executable',
1132+
'dependencies': [
1133+
'<(node_lib_target_name)',
1134+
],
1135+
'includes': [
1136+
'node.gypi'
1137+
],
1138+
'include_dirs': [
1139+
'src',
1140+
],
1141+
'defines': [
1142+
'NODE_ARCH="<(target_arch)"',
1143+
'NODE_PLATFORM="<(OS)"',
1144+
'NODE_WANT_INTERNALS=1',
1145+
],
1146+
'sources': [
1147+
'src/node_snapshot_stub.cc',
1148+
'src/node_code_cache_stub.cc',
1149+
'test/fuzzers/fuzz_url.cc',
1150+
],
1151+
'conditions': [
1152+
['OS=="linux"', {
1153+
'ldflags': [ '-fsanitize=fuzzer' ]
1154+
}],
1155+
# Ensure that ossfuzz flag has been set and that we are on Linux
1156+
[ 'OS!="linux" or ossfuzz!="true"', {
1157+
'type': 'none',
1158+
}],
1159+
],
1160+
}, # fuzz_url
11281161
{
11291162
'target_name': 'cctest',
11301163
'type': 'executable',
Collapse file

‎test/fuzzers/fuzz_url.cc‎

Copy file name to clipboard
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stdlib.h>
2+
3+
#include "node.h"
4+
#include "node_internals.h"
5+
#include "node_url.h"
6+
7+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
8+
node::url::URL url2(reinterpret_cast<const char*>(data), size);
9+
10+
return 0;
11+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.