aws-crt 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (322) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/VERSION +1 -1
  4. data/aws-crt-ffi/CMakeLists.txt +49 -41
  5. data/aws-crt-ffi/crt/aws-c-auth/CMakeLists.txt +0 -10
  6. data/aws-crt-ffi/crt/aws-c-auth/include/aws/auth/credentials.h +3 -2
  7. data/aws-crt-ffi/crt/aws-c-auth/include/aws/auth/private/credentials_utils.h +4 -4
  8. data/aws-crt-ffi/crt/aws-c-auth/source/auth.c +1 -14
  9. data/aws-crt-ffi/crt/aws-c-auth/source/aws_imds_client.c +206 -68
  10. data/aws-crt-ffi/crt/aws-c-auth/source/aws_signing.c +5 -0
  11. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_cached.c +6 -6
  12. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_default_chain.c +16 -1
  13. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_ecs.c +0 -1
  14. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_process.c +0 -1
  15. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_sts_web_identity.c +0 -1
  16. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_x509.c +10 -7
  17. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_utils.c +35 -26
  18. data/aws-crt-ffi/crt/aws-c-auth/source/signable_chunk.c +3 -2
  19. data/aws-crt-ffi/crt/aws-c-auth/tests/CMakeLists.txt +3 -2
  20. data/aws-crt-ffi/crt/aws-c-auth/tests/aws_imds_client_test.c +1 -0
  21. data/aws-crt-ffi/crt/aws-c-auth/tests/credentials_provider_ecs_tests.c +3 -0
  22. data/aws-crt-ffi/crt/aws-c-auth/tests/credentials_provider_process_tests.c +65 -16
  23. data/aws-crt-ffi/crt/aws-c-auth/tests/credentials_tests.c +125 -0
  24. data/aws-crt-ffi/crt/aws-c-auth/tests/sigv4_signing_tests.c +68 -46
  25. data/aws-crt-ffi/crt/aws-c-cal/CMakeLists.txt +8 -3
  26. data/aws-crt-ffi/crt/aws-c-cal/bin/run_x_platform_fuzz_corpus/main.c +9 -0
  27. data/aws-crt-ffi/crt/aws-c-cal/builder.json +11 -3
  28. data/aws-crt-ffi/crt/aws-c-cal/cmake/aws-c-cal-config.cmake +14 -5
  29. data/aws-crt-ffi/crt/aws-c-cal/source/darwin/securityframework_ecc.c +6 -6
  30. data/aws-crt-ffi/crt/aws-c-cal/source/windows/bcrypt_ecc.c +12 -12
  31. data/aws-crt-ffi/crt/aws-c-cal/tests/test_case_helper.h +14 -14
  32. data/aws-crt-ffi/crt/aws-c-common/CMakeLists.txt +21 -1
  33. data/aws-crt-ffi/crt/aws-c-common/README.md +8 -0
  34. data/aws-crt-ffi/crt/aws-c-common/cmake/AwsCFlags.cmake +20 -5
  35. data/aws-crt-ffi/crt/aws-c-common/cmake/AwsFeatureTests.cmake +7 -1
  36. data/aws-crt-ffi/crt/aws-c-common/format-check.sh +1 -1
  37. data/aws-crt-ffi/crt/aws-c-common/include/aws/common/byte_buf.h +14 -0
  38. data/aws-crt-ffi/crt/aws-c-common/include/aws/common/config.h.in +1 -0
  39. data/aws-crt-ffi/crt/{aws-c-auth/include/aws/auth → aws-c-common/include/aws/common}/external/cJSON.h +82 -74
  40. data/aws-crt-ffi/crt/aws-c-common/include/aws/common/json.h +335 -0
  41. data/aws-crt-ffi/crt/aws-c-common/include/aws/common/logging.h +1 -0
  42. data/aws-crt-ffi/crt/aws-c-common/include/aws/common/math.inl +2 -2
  43. data/aws-crt-ffi/crt/aws-c-common/include/aws/common/private/json_impl.h +22 -0
  44. data/aws-crt-ffi/crt/aws-c-common/include/aws/testing/aws_test_harness.h +2 -0
  45. data/aws-crt-ffi/crt/aws-c-common/source/byte_buf.c +36 -0
  46. data/aws-crt-ffi/crt/aws-c-common/source/common.c +5 -2
  47. data/aws-crt-ffi/crt/aws-c-common/source/external/cJSON.c +3113 -0
  48. data/aws-crt-ffi/crt/aws-c-common/source/file.c +9 -0
  49. data/aws-crt-ffi/crt/aws-c-common/source/json.c +348 -0
  50. data/aws-crt-ffi/crt/aws-c-common/source/logging.c +7 -2
  51. data/aws-crt-ffi/crt/aws-c-common/source/posix/system_info.c +8 -0
  52. data/aws-crt-ffi/crt/aws-c-common/source/ref_count.c +3 -1
  53. data/aws-crt-ffi/crt/aws-c-common/source/windows/file.c +47 -0
  54. data/aws-crt-ffi/crt/aws-c-common/source/windows/system_info.c +2 -1
  55. data/aws-crt-ffi/crt/aws-c-common/tests/CMakeLists.txt +5 -0
  56. data/aws-crt-ffi/crt/aws-c-common/tests/byte_buf_test.c +69 -0
  57. data/aws-crt-ffi/crt/aws-c-common/tests/json_test.c +134 -0
  58. data/aws-crt-ffi/crt/aws-c-common/tests/memtrace_test.c +6 -2
  59. data/aws-crt-ffi/crt/aws-c-event-stream/README.md +18 -35
  60. data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/event_stream.h +21 -2
  61. data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/event_stream_rpc_client.h +14 -2
  62. data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/event_stream_rpc_server.h +13 -0
  63. data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/private/event_stream_rpc_priv.h +7 -7
  64. data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream.c +257 -141
  65. data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream_channel_handler.c +1 -1
  66. data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream_rpc_client.c +31 -8
  67. data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream_rpc_server.c +63 -10
  68. data/aws-crt-ffi/crt/aws-c-event-stream/tests/CMakeLists.txt +2 -0
  69. data/aws-crt-ffi/crt/aws-c-event-stream/tests/event_stream_rpc_client_connection_test.c +157 -106
  70. data/aws-crt-ffi/crt/aws-c-event-stream/tests/event_stream_rpc_server_connection_test.c +168 -1
  71. data/aws-crt-ffi/crt/aws-c-event-stream/tests/message_deserializer_test.c +4 -2
  72. data/aws-crt-ffi/crt/aws-c-http/CMakeLists.txt +1 -0
  73. data/aws-crt-ffi/crt/aws-c-http/README.md +8 -0
  74. data/aws-crt-ffi/crt/aws-c-http/bin/elasticurl/main.c +1 -1
  75. data/aws-crt-ffi/crt/aws-c-http/builder.json +4 -3
  76. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/connection.h +8 -1
  77. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/connection_manager.h +45 -1
  78. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/http2_stream_manager.h +63 -12
  79. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/connection_impl.h +2 -1
  80. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/h2_connection.h +20 -2
  81. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/h2_frames.h +1 -0
  82. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/h2_stream.h +42 -13
  83. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/http2_stream_manager_impl.h +17 -0
  84. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/http_impl.h +3 -0
  85. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/random_access_set.h +10 -3
  86. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/request_response_impl.h +3 -17
  87. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/request_response.h +108 -4
  88. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/statistics.h +22 -0
  89. data/aws-crt-ffi/crt/aws-c-http/source/connection.c +8 -3
  90. data/aws-crt-ffi/crt/aws-c-http/source/connection_manager.c +22 -3
  91. data/aws-crt-ffi/crt/aws-c-http/source/connection_monitor.c +32 -14
  92. data/aws-crt-ffi/crt/aws-c-http/source/h1_connection.c +14 -0
  93. data/aws-crt-ffi/crt/aws-c-http/source/h1_encoder.c +7 -4
  94. data/aws-crt-ffi/crt/aws-c-http/source/h2_connection.c +161 -45
  95. data/aws-crt-ffi/crt/aws-c-http/source/h2_decoder.c +37 -8
  96. data/aws-crt-ffi/crt/aws-c-http/source/h2_frames.c +13 -1
  97. data/aws-crt-ffi/crt/aws-c-http/source/h2_stream.c +345 -87
  98. data/aws-crt-ffi/crt/aws-c-http/source/hpack.c +3 -0
  99. data/aws-crt-ffi/crt/aws-c-http/source/http.c +3 -0
  100. data/aws-crt-ffi/crt/aws-c-http/source/http2_stream_manager.c +266 -39
  101. data/aws-crt-ffi/crt/aws-c-http/source/random_access_set.c +9 -3
  102. data/aws-crt-ffi/crt/aws-c-http/source/request_response.c +80 -20
  103. data/aws-crt-ffi/crt/aws-c-http/source/statistics.c +11 -0
  104. data/aws-crt-ffi/crt/aws-c-http/tests/CMakeLists.txt +28 -1
  105. data/aws-crt-ffi/crt/aws-c-http/tests/fuzz/fuzz_h2_decoder_correct.c +5 -3
  106. data/aws-crt-ffi/crt/aws-c-http/tests/h2_test_helper.c +133 -29
  107. data/aws-crt-ffi/crt/aws-c-http/tests/h2_test_helper.h +6 -0
  108. data/aws-crt-ffi/crt/aws-c-http/tests/py_localhost/README.md +40 -0
  109. data/aws-crt-ffi/crt/aws-c-http/tests/py_localhost/non_tls_server.py +56 -0
  110. data/aws-crt-ffi/crt/aws-c-http/tests/py_localhost/server.py +329 -0
  111. data/aws-crt-ffi/crt/aws-c-http/tests/test_connection_manager.c +1 -1
  112. data/aws-crt-ffi/crt/aws-c-http/tests/test_connection_monitor.c +2 -2
  113. data/aws-crt-ffi/crt/aws-c-http/tests/test_h1_client.c +47 -34
  114. data/aws-crt-ffi/crt/aws-c-http/tests/test_h1_encoder.c +4 -4
  115. data/aws-crt-ffi/crt/aws-c-http/tests/test_h1_server.c +15 -12
  116. data/aws-crt-ffi/crt/aws-c-http/tests/test_h2_client.c +582 -25
  117. data/aws-crt-ffi/crt/aws-c-http/tests/test_h2_encoder.c +3 -3
  118. data/aws-crt-ffi/crt/aws-c-http/tests/test_localhost_integ.c +530 -0
  119. data/aws-crt-ffi/crt/aws-c-http/tests/test_stream_manager.c +459 -67
  120. data/aws-crt-ffi/crt/aws-c-io/CMakeLists.txt +4 -0
  121. data/aws-crt-ffi/crt/aws-c-io/builder.json +3 -2
  122. data/aws-crt-ffi/crt/aws-c-io/include/aws/io/channel.h +21 -0
  123. data/aws-crt-ffi/crt/aws-c-io/include/aws/io/io.h +3 -0
  124. data/aws-crt-ffi/crt/aws-c-io/include/aws/io/socket.h +6 -0
  125. data/aws-crt-ffi/crt/aws-c-io/include/aws/io/stream.h +35 -5
  126. data/aws-crt-ffi/crt/aws-c-io/include/aws/io/tls_channel_handler.h +211 -15
  127. data/aws-crt-ffi/crt/aws-c-io/source/channel.c +56 -30
  128. data/aws-crt-ffi/crt/aws-c-io/source/darwin/secure_transport_tls_channel_handler.c +0 -24
  129. data/aws-crt-ffi/crt/aws-c-io/source/io.c +9 -0
  130. data/aws-crt-ffi/crt/aws-c-io/source/{pkcs11.c → pkcs11_lib.c} +162 -22
  131. data/aws-crt-ffi/crt/aws-c-io/source/pkcs11_private.h +18 -20
  132. data/aws-crt-ffi/crt/aws-c-io/source/pkcs11_tls_op_handler.c +221 -0
  133. data/aws-crt-ffi/crt/aws-c-io/source/posix/socket.c +135 -81
  134. data/aws-crt-ffi/crt/aws-c-io/source/retry_strategy.c +12 -8
  135. data/aws-crt-ffi/crt/aws-c-io/source/s2n/s2n_tls_channel_handler.c +252 -215
  136. data/aws-crt-ffi/crt/aws-c-io/source/stream.c +65 -82
  137. data/aws-crt-ffi/crt/aws-c-io/source/tls_channel_handler.c +188 -57
  138. data/aws-crt-ffi/crt/aws-c-io/source/windows/iocp/socket.c +271 -256
  139. data/aws-crt-ffi/crt/aws-c-io/tests/CMakeLists.txt +21 -12
  140. data/aws-crt-ffi/crt/aws-c-io/tests/channel_test.c +32 -4
  141. data/aws-crt-ffi/crt/aws-c-io/tests/io_lib_test.c +37 -0
  142. data/aws-crt-ffi/crt/aws-c-io/tests/pkcs11_test.c +412 -93
  143. data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.crt +15 -0
  144. data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.key +5 -0
  145. data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.p12 +0 -0
  146. data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.p8 +5 -0
  147. data/aws-crt-ffi/crt/aws-c-io/tests/resources/generateCerts.sh +24 -15
  148. data/aws-crt-ffi/crt/aws-c-io/tests/socket_test.c +72 -1
  149. data/aws-crt-ffi/crt/s2n/CMakeLists.txt +6 -1
  150. data/aws-crt-ffi/crt/s2n/bindings/rust/Cargo.toml +1 -0
  151. data/aws-crt-ffi/crt/s2n/bindings/rust/generate/src/main.rs +105 -82
  152. data/aws-crt-ffi/crt/s2n/bindings/rust/generate.sh +1 -0
  153. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls/Cargo.toml +2 -2
  154. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls/src/raw/config.rs +1 -1
  155. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-sys/Cargo.toml +1 -1
  156. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-sys/build.rs +84 -30
  157. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-sys/src/lib.rs +4 -0
  158. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/Cargo.toml +21 -0
  159. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/certs/cert.pem +14 -0
  160. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/certs/key.pem +8 -0
  161. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/client.rs +45 -0
  162. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/server.rs +60 -0
  163. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/src/lib.rs +150 -0
  164. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/tests/handshake.rs +51 -0
  165. data/aws-crt-ffi/crt/s2n/crypto/s2n_drbg.c +98 -77
  166. data/aws-crt-ffi/crt/s2n/crypto/s2n_drbg.h +10 -7
  167. data/aws-crt-ffi/crt/s2n/crypto/s2n_openssl.h +2 -0
  168. data/aws-crt-ffi/crt/s2n/error/s2n_errno.c +1 -1
  169. data/aws-crt-ffi/crt/s2n/error/s2n_errno.h +1 -0
  170. data/aws-crt-ffi/crt/s2n/s2n.mk +7 -0
  171. data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/repository.py +233 -0
  172. data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/setup-proof.py +8 -7
  173. data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/setup.py +17 -18
  174. data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/util.py +41 -23
  175. data/aws-crt-ffi/crt/s2n/tests/fuzz/LD_PRELOAD/global_overrides.c +3 -3
  176. data/aws-crt-ffi/crt/s2n/tests/integration/s2n_client_endpoint_handshake_test.py +2 -2
  177. data/aws-crt-ffi/crt/s2n/tests/integrationv2/Makefile +13 -42
  178. data/aws-crt-ffi/crt/s2n/tests/integrationv2/README.md +6 -1
  179. data/aws-crt-ffi/crt/s2n/tests/integrationv2/common.py +118 -53
  180. data/aws-crt-ffi/crt/s2n/tests/integrationv2/configuration.py +108 -88
  181. data/aws-crt-ffi/crt/s2n/tests/integrationv2/conftest.py +6 -3
  182. data/aws-crt-ffi/crt/s2n/tests/integrationv2/constants.py +6 -4
  183. data/aws-crt-ffi/crt/s2n/tests/integrationv2/fixtures.py +21 -12
  184. data/aws-crt-ffi/crt/s2n/tests/integrationv2/global_flags.py +1 -0
  185. data/aws-crt-ffi/crt/s2n/tests/integrationv2/processes.py +62 -19
  186. data/aws-crt-ffi/crt/s2n/tests/integrationv2/providers.py +304 -48
  187. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_client_authentication.py +20 -11
  188. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_cross_compatibility.py +41 -17
  189. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_dynamic_record_sizes.py +6 -3
  190. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_early_data.py +105 -48
  191. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_external_psk.py +160 -76
  192. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_fragmentation.py +59 -26
  193. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_happy_path.py +42 -28
  194. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_hello_retry_requests.py +33 -13
  195. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_key_update.py +29 -11
  196. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_ocsp.py +138 -0
  197. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_pq_handshake.py +103 -36
  198. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_session_resumption.py +52 -25
  199. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_signature_algorithms.py +47 -21
  200. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_sni_match.py +13 -9
  201. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_sslyze.py +88 -17
  202. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_version_negotiation.py +71 -22
  203. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_well_known_endpoints.py +4 -3
  204. data/aws-crt-ffi/crt/s2n/tests/integrationv2/tox.ini +1 -0
  205. data/aws-crt-ffi/crt/s2n/tests/integrationv2/utils.py +50 -15
  206. data/aws-crt-ffi/crt/s2n/tests/litani/CHANGELOG +131 -0
  207. data/aws-crt-ffi/crt/s2n/tests/litani/CONTRIBUTING.md +16 -0
  208. data/aws-crt-ffi/crt/s2n/tests/litani/README.md +36 -14
  209. data/aws-crt-ffi/crt/s2n/tests/litani/THIRD-PARTY +205 -41
  210. data/aws-crt-ffi/crt/s2n/tests/litani/doc/bin/build-html-doc +7 -7
  211. data/aws-crt-ffi/crt/s2n/tests/litani/doc/configure +27 -23
  212. data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani-add-job.scdoc +7 -0
  213. data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani-dump-run.scdoc +7 -5
  214. data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani-transform-jobs.scdoc +248 -0
  215. data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani.scdoc +2 -2
  216. data/aws-crt-ffi/crt/s2n/tests/litani/doc/templates/index.jinja.html +4 -0
  217. data/aws-crt-ffi/crt/s2n/tests/litani/examples/add-root-node/README +12 -0
  218. data/aws-crt-ffi/crt/s2n/tests/litani/examples/add-root-node/original-run.sh +52 -0
  219. data/aws-crt-ffi/crt/s2n/tests/litani/examples/add-root-node/run-all.py +71 -0
  220. data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/README +13 -0
  221. data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-1.sh +34 -0
  222. data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-2.sh +35 -0
  223. data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-3.sh +34 -0
  224. data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-all.py +60 -0
  225. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/README.md +10 -0
  226. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/assumptions.html +42 -0
  227. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/file.dat +7 -0
  228. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/histogram.dat +7 -0
  229. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-1.sh +41 -0
  230. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-2.sh +47 -0
  231. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-3.sh +41 -0
  232. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-all.py +34 -0
  233. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/fib-table.py +40 -0
  234. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/fib.plt +5 -0
  235. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/fib.py +32 -0
  236. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/sin-output.py +40 -0
  237. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/sin.plt +5 -0
  238. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/sin.py +30 -0
  239. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/templates/fib-table.jinja.html +45 -0
  240. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/templates/sin-output.jinja.html +30 -0
  241. data/aws-crt-ffi/crt/s2n/tests/litani/lib/add_job.py +55 -0
  242. data/aws-crt-ffi/crt/s2n/tests/litani/lib/graph.py +2 -2
  243. data/aws-crt-ffi/crt/s2n/tests/litani/lib/litani.py +6 -1
  244. data/aws-crt-ffi/crt/s2n/tests/litani/lib/litani_report.py +18 -21
  245. data/aws-crt-ffi/crt/s2n/tests/litani/lib/ninja.py +2 -0
  246. data/aws-crt-ffi/crt/s2n/tests/litani/lib/run_printer.py +26 -7
  247. data/aws-crt-ffi/crt/s2n/tests/litani/lib/transform_jobs.py +84 -0
  248. data/aws-crt-ffi/crt/s2n/tests/litani/litani +28 -33
  249. data/aws-crt-ffi/crt/s2n/tests/litani/script/release +220 -0
  250. data/aws-crt-ffi/crt/s2n/tests/litani/templates/dashboard.jinja.html +78 -15
  251. data/aws-crt-ffi/crt/s2n/tests/litani/templates/pipeline.jinja.html +21 -5
  252. data/aws-crt-ffi/crt/s2n/tests/litani/test/README +15 -0
  253. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/run +56 -33
  254. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/custom_stages.py +1 -0
  255. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/cwd.py +1 -0
  256. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/dump_run.py +1 -0
  257. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/graph_line_break.py +1 -0
  258. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/html_node.py +1 -0
  259. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/job_id_env.py +1 -0
  260. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/multiproc_dump_run.py +1 -0
  261. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_pool_serialize.py +1 -0
  262. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_pool_serialize_graph.py +1 -0
  263. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_timed_out.py +1 -0
  264. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_timed_out_timeout_ignored.py +1 -0
  265. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_timed_out_timeout_ok.py +1 -0
  266. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/pipeline_order.py +53 -0
  267. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/pool_serialize.py +1 -0
  268. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/pool_serialize_graph.py +1 -0
  269. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/single_pool.py +1 -0
  270. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out.py +1 -0
  271. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_subprocess.py +1 -0
  272. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_subprocess_multi_shell.py +1 -0
  273. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_subprocess_shell.py +1 -0
  274. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_timeout_ignored.py +1 -0
  275. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_timeout_ok.py +1 -0
  276. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/transform_delete_job.py +54 -0
  277. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/transform_modify_job.py +46 -0
  278. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/transform_no_change_job.py +44 -0
  279. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/zero_pool.py +1 -0
  280. data/aws-crt-ffi/crt/s2n/tests/litani/test/run +82 -12
  281. data/aws-crt-ffi/crt/s2n/tests/s2n_test.h +58 -33
  282. data/aws-crt-ffi/crt/s2n/tests/testlib/s2n_key_schedule_testlib.c +18 -6
  283. data/aws-crt-ffi/crt/s2n/tests/testlib/s2n_pq_kat_test_utils.c +4 -4
  284. data/aws-crt-ffi/crt/s2n/tests/testlib/s2n_testlib.h +2 -0
  285. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_client_hello_retry_test.c +66 -2
  286. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_connection_test.c +1 -1
  287. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_drbg_test.c +34 -14
  288. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_fork_generation_number_test.c +28 -5
  289. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_mem_usage_test.c +6 -0
  290. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_override_openssl_random_test.c +1 -1
  291. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_random_test.c +60 -41
  292. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_self_talk_broken_pipe_test.c +2 -2
  293. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_handshake_early_data_test.c +3 -1
  294. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_hybrid_shared_secret_test.c +9 -1
  295. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_key_schedule_rfc8448_test.c +31 -130
  296. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_key_schedule_test.c +2 -4
  297. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_pq_handshake_test.c +11 -6
  298. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_secrets_rfc8448_test.c +19 -21
  299. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_secrets_test.c +109 -60
  300. data/aws-crt-ffi/crt/s2n/tls/s2n_config.c +1 -0
  301. data/aws-crt-ffi/crt/s2n/tls/s2n_config.h +1 -1
  302. data/aws-crt-ffi/crt/s2n/tls/s2n_connection.c +29 -24
  303. data/aws-crt-ffi/crt/s2n/tls/s2n_connection.h +5 -5
  304. data/aws-crt-ffi/crt/s2n/tls/s2n_handshake_hashes.h +1 -7
  305. data/aws-crt-ffi/crt/s2n/tls/s2n_handshake_io.c +2 -0
  306. data/aws-crt-ffi/crt/s2n/tls/s2n_handshake_transcript.c +0 -44
  307. data/aws-crt-ffi/crt/s2n/tls/s2n_internal.h +0 -1
  308. data/aws-crt-ffi/crt/s2n/tls/s2n_quic_support.h +1 -1
  309. data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_key_schedule.c +1 -2
  310. data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_secrets.c +84 -44
  311. data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_secrets.h +3 -9
  312. data/aws-crt-ffi/crt/s2n/utils/s2n_blob.h +15 -8
  313. data/aws-crt-ffi/crt/s2n/utils/s2n_fork_detection.c +2 -6
  314. data/aws-crt-ffi/crt/s2n/utils/s2n_random.c +9 -9
  315. data/aws-crt-ffi/src/input_stream.c +32 -15
  316. data/ext/compile.rb +13 -5
  317. data/lib/aws-crt/platforms.rb +14 -5
  318. data/lib/aws-crt/string_blob.rb +3 -3
  319. metadata +61 -7
  320. data/aws-crt-ffi/crt/aws-c-auth/source/external/cJSON.c +0 -2987
  321. data/aws-crt-ffi/crt/aws-c-auth/tests/external/cJSON.c +0 -2986
  322. data/aws-crt-ffi/crt/aws-c-io/tests/error_test.c +0 -20
@@ -12,6 +12,11 @@
12
12
  #include <errno.h>
13
13
 
14
14
  FILE *aws_fopen(const char *file_path, const char *mode) {
15
+ if (!file_path || strlen(file_path) == 0) {
16
+ AWS_LOGF_ERROR(AWS_LS_COMMON_IO, "static: Failed to open file %s", file_path);
17
+ return NULL;
18
+ }
19
+
15
20
  struct aws_string *file_path_str = aws_string_new_from_c_str(aws_default_allocator(), file_path);
16
21
  struct aws_string *mode_str = aws_string_new_from_c_str(aws_default_allocator(), mode);
17
22
 
@@ -23,6 +28,7 @@ FILE *aws_fopen(const char *file_path, const char *mode) {
23
28
  }
24
29
 
25
30
  int aws_byte_buf_init_from_file(struct aws_byte_buf *out_buf, struct aws_allocator *alloc, const char *filename) {
31
+
26
32
  AWS_ZERO_STRUCT(*out_buf);
27
33
  FILE *fp = aws_fopen(filename, "rb");
28
34
 
@@ -66,6 +72,9 @@ int aws_byte_buf_init_from_file(struct aws_byte_buf *out_buf, struct aws_allocat
66
72
 
67
73
  AWS_LOGF_ERROR(AWS_LS_COMMON_IO, "static: Failed to open file %s with errno %d", filename, errno);
68
74
 
75
+ if (errno == 0) {
76
+ return aws_raise_error(AWS_ERROR_FILE_INVALID_PATH);
77
+ }
69
78
  return aws_translate_and_raise_io_error(errno);
70
79
  }
71
80
 
@@ -0,0 +1,348 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0.
4
+ */
5
+
6
+ #include <aws/common/byte_buf.h>
7
+ #include <aws/common/string.h>
8
+
9
+ #include <aws/common/json.h>
10
+ #include <aws/common/private/json_impl.h>
11
+
12
+ #include <aws/common/external/cJSON.h>
13
+
14
+ static struct aws_allocator *s_aws_json_module_allocator = NULL;
15
+ static bool s_aws_json_module_initialized = false;
16
+
17
+ struct aws_json_value *aws_json_value_new_string(struct aws_allocator *allocator, struct aws_byte_cursor string) {
18
+ struct aws_string *tmp = aws_string_new_from_cursor((struct aws_allocator *)allocator, &string);
19
+ void *ret_val = cJSON_CreateString(aws_string_c_str(tmp));
20
+ aws_string_destroy_secure(tmp);
21
+ return ret_val;
22
+ }
23
+
24
+ struct aws_json_value *aws_json_value_new_number(struct aws_allocator *allocator, double number) {
25
+ (void)allocator; // prevent warnings over unused parameter
26
+ return (void *)cJSON_CreateNumber(number);
27
+ }
28
+
29
+ struct aws_json_value *aws_json_value_new_array(struct aws_allocator *allocator) {
30
+ (void)allocator; // prevent warnings over unused parameter
31
+ return (void *)cJSON_CreateArray();
32
+ }
33
+
34
+ struct aws_json_value *aws_json_value_new_boolean(struct aws_allocator *allocator, bool boolean) {
35
+ (void)allocator; // prevent warnings over unused parameter
36
+ return (void *)cJSON_CreateBool(boolean);
37
+ }
38
+
39
+ struct aws_json_value *aws_json_value_new_null(struct aws_allocator *allocator) {
40
+ (void)allocator; // prevent warnings over unused parameter
41
+ return (void *)cJSON_CreateNull();
42
+ }
43
+
44
+ struct aws_json_value *aws_json_value_new_object(struct aws_allocator *allocator) {
45
+ (void)allocator; // prevent warnings over unused parameter
46
+ return (void *)cJSON_CreateObject();
47
+ }
48
+
49
+ int aws_json_value_get_string(const struct aws_json_value *value, struct aws_byte_cursor *output) {
50
+ struct cJSON *cjson = (struct cJSON *)value;
51
+ if (!cJSON_IsString(cjson)) {
52
+ return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
53
+ }
54
+ *output = aws_byte_cursor_from_c_str(cJSON_GetStringValue(cjson));
55
+ return AWS_OP_SUCCESS;
56
+ }
57
+
58
+ int aws_json_value_get_number(const struct aws_json_value *value, double *output) {
59
+ struct cJSON *cjson = (struct cJSON *)value;
60
+ if (!cJSON_IsNumber(cjson)) {
61
+ return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
62
+ }
63
+ *output = cjson->valuedouble;
64
+ return AWS_OP_SUCCESS;
65
+ }
66
+
67
+ int aws_json_value_get_boolean(const struct aws_json_value *value, bool *output) {
68
+ struct cJSON *cjson = (struct cJSON *)value;
69
+ if (!cJSON_IsBool(cjson)) {
70
+ return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
71
+ }
72
+ *output = cjson->type == cJSON_True;
73
+ return AWS_OP_SUCCESS;
74
+ }
75
+
76
+ int aws_json_value_add_to_object(
77
+ struct aws_json_value *object,
78
+ struct aws_byte_cursor key,
79
+ struct aws_json_value *value) {
80
+
81
+ int result = AWS_OP_ERR;
82
+ struct aws_string *tmp = aws_string_new_from_cursor(s_aws_json_module_allocator, &key);
83
+
84
+ struct cJSON *cjson = (struct cJSON *)object;
85
+ if (!cJSON_IsObject(cjson)) {
86
+ aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
87
+ goto done;
88
+ }
89
+
90
+ struct cJSON *cjson_value = (struct cJSON *)value;
91
+ if (cJSON_IsInvalid(cjson_value)) {
92
+ result = aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
93
+ goto done;
94
+ }
95
+ if (cJSON_HasObjectItem(cjson, aws_string_c_str(tmp))) {
96
+ goto done;
97
+ }
98
+
99
+ cJSON_AddItemToObject(cjson, aws_string_c_str(tmp), cjson_value);
100
+ result = AWS_OP_SUCCESS;
101
+
102
+ done:
103
+ aws_string_destroy_secure(tmp);
104
+ return result;
105
+ }
106
+
107
+ struct aws_json_value *aws_json_value_get_from_object(const struct aws_json_value *object, struct aws_byte_cursor key) {
108
+
109
+ void *return_value = NULL;
110
+ struct aws_string *tmp = aws_string_new_from_cursor(s_aws_json_module_allocator, &key);
111
+
112
+ struct cJSON *cjson = (struct cJSON *)object;
113
+ if (!cJSON_IsObject(cjson)) {
114
+ aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
115
+ goto done;
116
+ }
117
+ if (!cJSON_HasObjectItem(cjson, aws_string_c_str(tmp))) {
118
+ goto done;
119
+ }
120
+
121
+ return_value = (void *)cJSON_GetObjectItem(cjson, aws_string_c_str(tmp));
122
+
123
+ done:
124
+ aws_string_destroy_secure(tmp);
125
+ return return_value;
126
+ }
127
+
128
+ bool aws_json_value_has_key(const struct aws_json_value *object, struct aws_byte_cursor key) {
129
+
130
+ struct aws_string *tmp = aws_string_new_from_cursor(s_aws_json_module_allocator, &key);
131
+ bool result = false;
132
+
133
+ struct cJSON *cjson = (struct cJSON *)object;
134
+ if (!cJSON_IsObject(cjson)) {
135
+ goto done;
136
+ }
137
+ if (!cJSON_HasObjectItem(cjson, aws_string_c_str(tmp))) {
138
+ goto done;
139
+ }
140
+ result = true;
141
+
142
+ done:
143
+ aws_string_destroy_secure(tmp);
144
+ return result;
145
+ }
146
+
147
+ int aws_json_value_remove_from_object(struct aws_json_value *object, struct aws_byte_cursor key) {
148
+
149
+ int result = AWS_OP_ERR;
150
+ struct aws_string *tmp = aws_string_new_from_cursor(s_aws_json_module_allocator, &key);
151
+
152
+ struct cJSON *cjson = (struct cJSON *)object;
153
+ if (!cJSON_IsObject(cjson)) {
154
+ aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
155
+ goto done;
156
+ }
157
+ if (!cJSON_HasObjectItem(cjson, aws_string_c_str(tmp))) {
158
+ goto done;
159
+ }
160
+
161
+ cJSON_DeleteItemFromObject(cjson, aws_string_c_str(tmp));
162
+ result = AWS_OP_SUCCESS;
163
+
164
+ done:
165
+ aws_string_destroy_secure(tmp);
166
+ return result;
167
+ }
168
+
169
+ int aws_json_value_add_array_element(struct aws_json_value *array, const struct aws_json_value *value) {
170
+
171
+ struct cJSON *cjson = (struct cJSON *)array;
172
+ if (!cJSON_IsArray(cjson)) {
173
+ return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
174
+ }
175
+
176
+ struct cJSON *cjson_value = (struct cJSON *)value;
177
+ if (cJSON_IsInvalid(cjson_value)) {
178
+ return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
179
+ }
180
+
181
+ cJSON_AddItemToArray(cjson, cjson_value);
182
+ return AWS_OP_SUCCESS;
183
+ }
184
+
185
+ struct aws_json_value *aws_json_get_array_element(const struct aws_json_value *array, size_t index) {
186
+
187
+ struct cJSON *cjson = (struct cJSON *)array;
188
+ if (!cJSON_IsArray(cjson)) {
189
+ aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
190
+ return NULL;
191
+ }
192
+
193
+ if (index > (size_t)cJSON_GetArraySize(cjson)) {
194
+ aws_raise_error(AWS_ERROR_INVALID_INDEX);
195
+ return NULL;
196
+ }
197
+
198
+ return (void *)cJSON_GetArrayItem(cjson, (int)index);
199
+ }
200
+
201
+ size_t aws_json_get_array_size(const struct aws_json_value *array) {
202
+ struct cJSON *cjson = (struct cJSON *)array;
203
+ if (!cJSON_IsArray(cjson)) {
204
+ aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
205
+ return 0;
206
+ }
207
+ return cJSON_GetArraySize(cjson);
208
+ }
209
+
210
+ int aws_json_value_remove_array_element(struct aws_json_value *array, size_t index) {
211
+
212
+ struct cJSON *cjson = (struct cJSON *)array;
213
+ if (!cJSON_IsArray(cjson)) {
214
+ return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
215
+ }
216
+
217
+ if (index > (size_t)cJSON_GetArraySize(cjson)) {
218
+ return aws_raise_error(AWS_ERROR_INVALID_INDEX);
219
+ }
220
+
221
+ cJSON_DeleteItemFromArray(cjson, (int)index);
222
+ return AWS_OP_SUCCESS;
223
+ }
224
+
225
+ bool aws_json_value_is_string(const struct aws_json_value *value) {
226
+ struct cJSON *cjson = (struct cJSON *)value;
227
+ if (cJSON_IsInvalid(cjson)) {
228
+ return false;
229
+ }
230
+ return cJSON_IsString(cjson);
231
+ }
232
+
233
+ bool aws_json_value_is_number(const struct aws_json_value *value) {
234
+ struct cJSON *cjson = (struct cJSON *)value;
235
+ if (cJSON_IsInvalid(cjson)) {
236
+ return false;
237
+ }
238
+ return cJSON_IsNumber(cjson);
239
+ }
240
+
241
+ bool aws_json_value_is_array(const struct aws_json_value *value) {
242
+ struct cJSON *cjson = (struct cJSON *)value;
243
+ if (cJSON_IsInvalid(cjson)) {
244
+ return false;
245
+ }
246
+ return cJSON_IsArray(cjson);
247
+ }
248
+
249
+ bool aws_json_value_is_boolean(const struct aws_json_value *value) {
250
+ struct cJSON *cjson = (struct cJSON *)value;
251
+ if (cJSON_IsInvalid(cjson)) {
252
+ return false;
253
+ }
254
+ return cJSON_IsBool(cjson);
255
+ }
256
+
257
+ bool aws_json_value_is_null(const struct aws_json_value *value) {
258
+ struct cJSON *cjson = (struct cJSON *)value;
259
+ if (cJSON_IsInvalid(cjson)) {
260
+ return false;
261
+ }
262
+ return cJSON_IsNull(cjson);
263
+ }
264
+
265
+ bool aws_json_value_is_object(const struct aws_json_value *value) {
266
+ struct cJSON *cjson = (struct cJSON *)value;
267
+ if (cJSON_IsInvalid(cjson)) {
268
+ return false;
269
+ }
270
+ return cJSON_IsObject(cjson);
271
+ }
272
+
273
+ static void *s_aws_cJSON_alloc(size_t sz) {
274
+ return aws_mem_acquire(s_aws_json_module_allocator, sz);
275
+ }
276
+
277
+ static void s_aws_cJSON_free(void *ptr) {
278
+ aws_mem_release(s_aws_json_module_allocator, ptr);
279
+ }
280
+
281
+ void aws_json_module_init(struct aws_allocator *allocator) {
282
+ if (!s_aws_json_module_initialized) {
283
+ s_aws_json_module_allocator = allocator;
284
+ struct cJSON_Hooks allocation_hooks = {
285
+ .malloc_fn = s_aws_cJSON_alloc,
286
+ .free_fn = s_aws_cJSON_free,
287
+ };
288
+ cJSON_InitHooks(&allocation_hooks);
289
+ s_aws_json_module_initialized = true;
290
+ }
291
+ }
292
+
293
+ void aws_json_module_cleanup(void) {
294
+ if (s_aws_json_module_initialized) {
295
+ s_aws_json_module_allocator = NULL;
296
+ s_aws_json_module_initialized = false;
297
+ }
298
+ }
299
+
300
+ void aws_json_value_destroy(struct aws_json_value *value) {
301
+ struct cJSON *cjson = (struct cJSON *)value;
302
+ if (!cJSON_IsInvalid(cjson)) {
303
+ cJSON_Delete(cjson);
304
+ }
305
+ }
306
+
307
+ int aws_byte_buf_append_json_string(const struct aws_json_value *value, struct aws_byte_buf *output) {
308
+ struct cJSON *cjson = (struct cJSON *)value;
309
+ if (cJSON_IsInvalid(cjson)) {
310
+ return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
311
+ }
312
+
313
+ char *tmp = cJSON_PrintUnformatted(cjson);
314
+ if (tmp == NULL) {
315
+ return AWS_OP_ERR;
316
+ }
317
+
318
+ // Append the text to the byte buffer
319
+ struct aws_byte_cursor tmp_cursor = aws_byte_cursor_from_c_str(tmp);
320
+ int return_val = aws_byte_buf_append_dynamic_secure(output, &tmp_cursor);
321
+ s_aws_cJSON_free(tmp); // free the char* now that we do not need it
322
+ return return_val;
323
+ }
324
+
325
+ int aws_byte_buf_append_json_string_formatted(const struct aws_json_value *value, struct aws_byte_buf *output) {
326
+ struct cJSON *cjson = (struct cJSON *)value;
327
+ if (cJSON_IsInvalid(cjson)) {
328
+ return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
329
+ }
330
+
331
+ char *tmp = cJSON_Print(cjson);
332
+ if (tmp == NULL) {
333
+ return AWS_OP_ERR;
334
+ }
335
+
336
+ // Append the text to the byte buffer
337
+ struct aws_byte_cursor tmp_cursor = aws_byte_cursor_from_c_str(tmp);
338
+ int return_val = aws_byte_buf_append_dynamic_secure(output, &tmp_cursor);
339
+ s_aws_cJSON_free(tmp); // free the char* now that we do not need it
340
+ return return_val;
341
+ }
342
+
343
+ struct aws_json_value *aws_json_value_new_from_string(struct aws_allocator *allocator, struct aws_byte_cursor string) {
344
+ struct aws_string *tmp = aws_string_new_from_cursor((struct aws_allocator *)allocator, &string);
345
+ struct cJSON *cjson = cJSON_Parse(aws_string_c_str(tmp));
346
+ aws_string_destroy_secure(tmp);
347
+ return (void *)cjson;
348
+ }
@@ -547,8 +547,13 @@ int aws_logger_init_noalloc(
547
547
  impl->file = options->file;
548
548
  impl->should_close = false;
549
549
  } else { /* _MSC_VER */
550
- impl->file = aws_fopen(options->filename, "w");
551
- impl->should_close = true;
550
+ if (options->filename != NULL) {
551
+ impl->file = aws_fopen(options->filename, "w");
552
+ impl->should_close = true;
553
+ } else {
554
+ impl->file = stderr;
555
+ impl->should_close = false;
556
+ }
552
557
  }
553
558
 
554
559
  aws_mutex_init(&impl->lock);
@@ -14,6 +14,14 @@
14
14
  # define __BSD_VISIBLE 1
15
15
  #endif
16
16
 
17
+ #if defined(__linux__)
18
+ # include <sys/sysinfo.h>
19
+ #endif
20
+
21
+ #if defined(__linux__) || defined(__unix__)
22
+ # include <sys/types.h>
23
+ #endif
24
+
17
25
  #include <unistd.h>
18
26
 
19
27
  #if defined(HAVE_SYSCONF)
@@ -15,7 +15,9 @@ void aws_ref_count_init(struct aws_ref_count *ref_count, void *object, aws_simpl
15
15
  }
16
16
 
17
17
  void *aws_ref_count_acquire(struct aws_ref_count *ref_count) {
18
- aws_atomic_fetch_add(&ref_count->ref_count, 1);
18
+ size_t old_value = aws_atomic_fetch_add(&ref_count->ref_count, 1);
19
+ AWS_ASSERT(old_value > 0 && "refcount has been zero, it's invalid to use it again.");
20
+ (void)old_value;
19
21
 
20
22
  return ref_count->object;
21
23
  }
@@ -13,7 +13,19 @@
13
13
  #include <stdio.h>
14
14
  #include <windows.h>
15
15
 
16
+ static bool s_is_string_empty(const struct aws_string *str) {
17
+ return str == NULL || str->len == 0;
18
+ }
19
+
20
+ static bool s_is_wstring_empty(const struct aws_wstring *str) {
21
+ return str == NULL || str->len == 0;
22
+ }
23
+
16
24
  FILE *aws_fopen_safe(const struct aws_string *file_path, const struct aws_string *mode) {
25
+ if (s_is_string_empty(file_path) || s_is_string_empty(mode)) {
26
+ return NULL;
27
+ }
28
+
17
29
  struct aws_wstring *w_file_path = aws_string_convert_to_wstring(aws_default_allocator(), file_path);
18
30
  struct aws_wstring *w_mode = aws_string_convert_to_wstring(aws_default_allocator(), mode);
19
31
 
@@ -31,6 +43,9 @@ FILE *aws_fopen_safe(const struct aws_string *file_path, const struct aws_string
31
43
  }
32
44
 
33
45
  struct aws_wstring *s_to_long_path(struct aws_allocator *allocator, const struct aws_wstring *path) {
46
+ if (s_is_wstring_empty(path)) {
47
+ return NULL;
48
+ }
34
49
 
35
50
  wchar_t prefix[] = L"\\\\?\\";
36
51
  size_t prefix_size = sizeof(prefix);
@@ -56,6 +71,10 @@ struct aws_wstring *s_to_long_path(struct aws_allocator *allocator, const struct
56
71
  }
57
72
 
58
73
  int aws_directory_create(const struct aws_string *dir_path) {
74
+ if (s_is_string_empty(dir_path)) {
75
+ return aws_raise_error(AWS_ERROR_FILE_INVALID_PATH);
76
+ }
77
+
59
78
  struct aws_wstring *w_dir_path = aws_string_convert_to_wstring(aws_default_allocator(), dir_path);
60
79
  struct aws_wstring *long_dir_path = s_to_long_path(aws_default_allocator(), w_dir_path);
61
80
  aws_wstring_destroy(w_dir_path);
@@ -84,6 +103,10 @@ int aws_directory_create(const struct aws_string *dir_path) {
84
103
  }
85
104
 
86
105
  bool aws_directory_exists(const struct aws_string *dir_path) {
106
+ if (s_is_string_empty(dir_path)) {
107
+ return false;
108
+ }
109
+
87
110
  struct aws_wstring *w_dir_path = aws_string_convert_to_wstring(aws_default_allocator(), dir_path);
88
111
  struct aws_wstring *long_dir_path = s_to_long_path(aws_default_allocator(), w_dir_path);
89
112
  aws_wstring_destroy(w_dir_path);
@@ -115,6 +138,9 @@ static bool s_delete_file_or_directory(const struct aws_directory_entry *entry,
115
138
  }
116
139
 
117
140
  int aws_directory_delete(const struct aws_string *dir_path, bool recursive) {
141
+ if (s_is_string_empty(dir_path)) {
142
+ return aws_raise_error(AWS_ERROR_FILE_INVALID_PATH);
143
+ }
118
144
  if (!aws_directory_exists(dir_path)) {
119
145
  return AWS_OP_SUCCESS;
120
146
  }
@@ -158,6 +184,10 @@ int aws_directory_delete(const struct aws_string *dir_path, bool recursive) {
158
184
  }
159
185
 
160
186
  int aws_file_delete(const struct aws_string *file_path) {
187
+ if (s_is_string_empty(file_path)) {
188
+ return aws_raise_error(AWS_ERROR_FILE_INVALID_PATH);
189
+ }
190
+
161
191
  struct aws_wstring *w_file_path = aws_string_convert_to_wstring(aws_default_allocator(), file_path);
162
192
  struct aws_wstring *long_file_path = s_to_long_path(aws_default_allocator(), w_file_path);
163
193
  aws_wstring_destroy(w_file_path);
@@ -182,6 +212,10 @@ int aws_file_delete(const struct aws_string *file_path) {
182
212
  }
183
213
 
184
214
  int aws_directory_or_file_move(const struct aws_string *from, const struct aws_string *to) {
215
+ if (s_is_string_empty(from) || s_is_string_empty(to)) {
216
+ return aws_raise_error(AWS_ERROR_FILE_INVALID_PATH);
217
+ }
218
+
185
219
  struct aws_wstring *w_from_path = aws_string_convert_to_wstring(aws_default_allocator(), from);
186
220
  struct aws_wstring *long_from_path = s_to_long_path(aws_default_allocator(), w_from_path);
187
221
  aws_wstring_destroy(w_from_path);
@@ -216,6 +250,11 @@ int aws_directory_traverse(
216
250
  bool recursive,
217
251
  aws_on_directory_entry *on_entry,
218
252
  void *user_data) {
253
+
254
+ if (s_is_string_empty(path)) {
255
+ return aws_raise_error(AWS_ERROR_FILE_INVALID_PATH);
256
+ }
257
+
219
258
  struct aws_wstring *w_path_wchar = aws_string_convert_to_wstring(allocator, path);
220
259
  struct aws_wstring *long_path_wchar = s_to_long_path(allocator, w_path_wchar);
221
260
  aws_wstring_destroy(w_path_wchar);
@@ -440,6 +479,10 @@ struct aws_string *aws_get_home_directory(struct aws_allocator *allocator) {
440
479
  }
441
480
 
442
481
  bool aws_path_exists(const struct aws_string *path) {
482
+ if (s_is_string_empty(path)) {
483
+ return false;
484
+ }
485
+
443
486
  struct aws_wstring *wchar_path = aws_string_convert_to_wstring(aws_default_allocator(), path);
444
487
  bool ret_val = PathFileExistsW(aws_wstring_c_str(wchar_path)) == TRUE;
445
488
  aws_wstring_destroy(wchar_path);
@@ -455,6 +498,10 @@ int aws_fseek(FILE *file, int64_t offset, int whence) {
455
498
  }
456
499
 
457
500
  int aws_file_get_length(FILE *file, int64_t *length) {
501
+ if (file == NULL) {
502
+ return aws_raise_error(AWS_ERROR_INVALID_FILE_HANDLE);
503
+ }
504
+
458
505
  int fd = _fileno(file);
459
506
  if (fd == -1) {
460
507
  return aws_raise_error(AWS_ERROR_INVALID_FILE_HANDLE);
@@ -272,7 +272,7 @@ void aws_backtrace_log(int log_level) {
272
272
  }
273
273
  aws_mem_release(aws_default_allocator(), symbols);
274
274
  }
275
- #else /* !AWS_OS_WINDOWS_DESKTOP */
275
+ #else /* !AWS_OS_WINDOWS_DESKTOP */
276
276
  size_t aws_backtrace(void **stack_frames, size_t size) {
277
277
  (void)stack_frames;
278
278
  (void)size;
@@ -299,4 +299,5 @@ void aws_backtrace_log() {
299
299
  AWS_LOGF_TRACE(
300
300
  AWS_LS_COMMON_GENERAL, "aws_backtrace_log: backtrace requested, but logging is unsupported on this platform");
301
301
  }
302
+
302
303
  #endif /* AWS_OS_WINDOWS_DESKTOP */
@@ -277,6 +277,8 @@ add_test_case(test_byte_buf_reserve_relative)
277
277
  add_test_case(test_byte_buf_reset)
278
278
  add_test_case(test_byte_cursor_compare_lexical)
279
279
  add_test_case(test_byte_cursor_compare_lookup)
280
+ add_test_case(test_byte_cursor_starts_with)
281
+ add_test_case(test_byte_cursor_starts_with_ignore_case)
280
282
  add_test_case(test_isalnum)
281
283
  add_test_case(test_isalpha)
282
284
  add_test_case(test_isdigit)
@@ -474,6 +476,9 @@ add_test_case(promise_test_finish_immediately)
474
476
  add_test_case(promise_test_finish_before_wait)
475
477
  add_test_case(promise_test_multiple_waiters)
476
478
 
479
+ add_test_case(test_json_parse_from_string)
480
+ add_test_case(test_json_parse_to_string)
481
+
477
482
  generate_test_driver(${PROJECT_NAME}-tests)
478
483
 
479
484
  if (NOT MSVC AND NOT LEGACY_COMPILER_SUPPORT)
@@ -798,6 +798,75 @@ static int s_test_byte_buf_reserve_relative(struct aws_allocator *allocator, voi
798
798
  }
799
799
  AWS_TEST_CASE(test_byte_buf_reserve_relative, s_test_byte_buf_reserve_relative)
800
800
 
801
+ static int s_test_byte_cursor_starts_with(struct aws_allocator *allocator, void *ctx) {
802
+ (void)ctx;
803
+ (void)allocator;
804
+
805
+ struct aws_byte_cursor a = aws_byte_cursor_from_c_str("a");
806
+ struct aws_byte_cursor abcd = aws_byte_cursor_from_c_str("abcd");
807
+ struct aws_byte_cursor ab = aws_byte_cursor_from_c_str("ab");
808
+ struct aws_byte_cursor abcde = aws_byte_cursor_from_c_str("abcde");
809
+ struct aws_byte_cursor ABCD = aws_byte_cursor_from_c_str("ABCD");
810
+ struct aws_byte_cursor AB = aws_byte_cursor_from_c_str("AB");
811
+ struct aws_byte_cursor empty_string = aws_byte_cursor_from_c_str("");
812
+ struct aws_byte_cursor null_char_string = aws_byte_cursor_from_array("\0", 1);
813
+
814
+ /* TRUE */
815
+ ASSERT_TRUE(aws_byte_cursor_starts_with(&a, &a));
816
+ ASSERT_TRUE(aws_byte_cursor_starts_with(&abcd, &ab));
817
+ ASSERT_TRUE(aws_byte_cursor_starts_with(&abcd, &abcd));
818
+ ASSERT_TRUE(aws_byte_cursor_starts_with(&abcd, &empty_string));
819
+ ASSERT_TRUE(aws_byte_cursor_starts_with(&empty_string, &empty_string));
820
+
821
+ /* FALSE */
822
+ ASSERT_FALSE(aws_byte_cursor_starts_with(&abcd, &abcde));
823
+ ASSERT_FALSE(aws_byte_cursor_starts_with(&abcd, &ABCD));
824
+ ASSERT_FALSE(aws_byte_cursor_starts_with(&abcd, &AB));
825
+ ASSERT_FALSE(aws_byte_cursor_starts_with(&empty_string, &a));
826
+ ASSERT_FALSE(aws_byte_cursor_starts_with(&empty_string, &null_char_string));
827
+ ASSERT_FALSE(aws_byte_cursor_starts_with(&abcd, &null_char_string));
828
+
829
+ return 0;
830
+ }
831
+ AWS_TEST_CASE(test_byte_cursor_starts_with, s_test_byte_cursor_starts_with)
832
+
833
+ static int s_test_byte_cursor_starts_with_ignore_case(struct aws_allocator *allocator, void *ctx) {
834
+ (void)ctx;
835
+ (void)allocator;
836
+
837
+ struct aws_byte_cursor a = aws_byte_cursor_from_c_str("a");
838
+ struct aws_byte_cursor A = aws_byte_cursor_from_c_str("A");
839
+ struct aws_byte_cursor abcd = aws_byte_cursor_from_c_str("abcd");
840
+ struct aws_byte_cursor ABCD = aws_byte_cursor_from_c_str("ABCD");
841
+ struct aws_byte_cursor abcde = aws_byte_cursor_from_c_str("abcde");
842
+ struct aws_byte_cursor azcd = aws_byte_cursor_from_c_str("azcd");
843
+ struct aws_byte_cursor empty_string = aws_byte_cursor_from_c_str("");
844
+ struct aws_byte_cursor null_char_string = aws_byte_cursor_from_array("\0", 1);
845
+
846
+ /* TRUE */
847
+ ASSERT_TRUE(aws_byte_cursor_starts_with_ignore_case(&abcd, &abcd));
848
+ ASSERT_TRUE(aws_byte_cursor_starts_with_ignore_case(&abcd, &ABCD));
849
+ ASSERT_TRUE(aws_byte_cursor_starts_with_ignore_case(&ABCD, &abcd));
850
+ ASSERT_TRUE(aws_byte_cursor_starts_with_ignore_case(&ABCD, &ABCD));
851
+
852
+ ASSERT_TRUE(aws_byte_cursor_starts_with_ignore_case(&abcd, &a));
853
+ ASSERT_TRUE(aws_byte_cursor_starts_with_ignore_case(&abcd, &A));
854
+ ASSERT_TRUE(aws_byte_cursor_starts_with_ignore_case(&ABCD, &a));
855
+ ASSERT_TRUE(aws_byte_cursor_starts_with_ignore_case(&ABCD, &A));
856
+
857
+ ASSERT_TRUE(aws_byte_cursor_starts_with_ignore_case(&abcd, &empty_string));
858
+ ASSERT_TRUE(aws_byte_cursor_starts_with_ignore_case(&empty_string, &empty_string));
859
+
860
+ /* FALSE */
861
+ ASSERT_FALSE(aws_byte_cursor_starts_with_ignore_case(&abcd, &abcde));
862
+ ASSERT_FALSE(aws_byte_cursor_starts_with_ignore_case(&abcd, &azcd));
863
+ ASSERT_FALSE(aws_byte_cursor_starts_with_ignore_case(&empty_string, &a));
864
+ ASSERT_FALSE(aws_byte_cursor_starts_with_ignore_case(&empty_string, &null_char_string));
865
+
866
+ return 0;
867
+ }
868
+ AWS_TEST_CASE(test_byte_cursor_starts_with_ignore_case, s_test_byte_cursor_starts_with_ignore_case)
869
+
801
870
  static int s_test_byte_cursor_compare_lexical(struct aws_allocator *allocator, void *ctx) {
802
871
  (void)ctx;
803
872
  (void)allocator;