|
11 | 11 | "xcode_settings": { |
12 | 12 | "CLANG_CXX_LIBRARY": "libc++", |
13 | 13 | "MACOSX_DEPLOYMENT_TARGET": "10.7", |
| 14 | + "OTHER_CFLAGS": [ "-fstack-protector-strong" ] |
14 | 15 | }, |
15 | 16 | "include_dirs": [ |
16 | 17 | "<!@(node -p \"require('node-addon-api').include\")"], |
|
39 | 40 | "deps/sqlite3.gyp:sqlite3" |
40 | 41 | ] |
41 | 42 | } |
42 | | - ] |
| 43 | + ], |
| 44 | + # Linux hardening flags (apply to all builds) |
| 45 | + ["OS=='linux'", { |
| 46 | + "cflags+": [ |
| 47 | + "-fstack-protector-strong", |
| 48 | + "-fPIC" |
| 49 | + ], |
| 50 | + "ldflags+": [ "-Wl,-z,relro,-z,now" ] |
| 51 | + }], |
| 52 | + # Windows hardening flags (apply to all builds) |
| 53 | + ["OS=='win'", { |
| 54 | + "msvs_settings": { |
| 55 | + "VCCLCompilerTool": { |
| 56 | + "ExceptionHandling": 1, |
| 57 | + "BufferSecurityCheck": "true", |
| 58 | + "ControlFlowGuard": "Guard" |
| 59 | + }, |
| 60 | + "VCLinkerTool": { |
| 61 | + "AdditionalOptions": [ "/DYNAMICBASE", "/NXCOMPAT" ] |
| 62 | + } |
| 63 | + } |
| 64 | + }] |
43 | 65 | ], |
44 | 66 | "sources": [ |
45 | 67 | "src/backup.cc", |
46 | 68 | "src/database.cc", |
47 | 69 | "src/node_sqlite3.cc", |
48 | 70 | "src/statement.cc" |
49 | 71 | ], |
50 | | - "defines": [ "NAPI_VERSION=<(napi_build_version)" ] |
| 72 | + "defines": [ "NAPI_VERSION=<(napi_build_version)" ], |
| 73 | + # Release-specific hardening flags |
| 74 | + "configurations": { |
| 75 | + "Release": { |
| 76 | + "conditions": [ |
| 77 | + # _FORTIFY_SOURCE applies to all Linux architectures |
| 78 | + ["OS=='linux'", { |
| 79 | + "defines+": [ "_FORTIFY_SOURCE=2" ] |
| 80 | + }], |
| 81 | + # Control Flow Protection only for x86_64 (Intel CET) |
| 82 | + ["OS=='linux' and target_arch=='x64'", { |
| 83 | + "cflags+": [ "-fcf-protection=full" ] |
| 84 | + }], |
| 85 | + ["OS=='win'", { |
| 86 | + "msvs_settings": { |
| 87 | + "VCCLCompilerTool": { |
| 88 | + "AdditionalOptions": [ "/sdl" ] |
| 89 | + } |
| 90 | + } |
| 91 | + }] |
| 92 | + ] |
| 93 | + } |
| 94 | + } |
51 | 95 | } |
52 | 96 | ] |
53 | 97 | } |
0 commit comments