Skip to content

Commit

Permalink
Merge branch 'development' into default_message_reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
kLabz committed Apr 30, 2024
2 parents 193c13a + c325889 commit 70b4d3c
Show file tree
Hide file tree
Showing 140 changed files with 1,405 additions and 538 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-latest, macos-14]
os: [macos-14, macos-13]
runs-on: ${{ matrix.os }}
env:
PLATFORM: mac
Expand Down Expand Up @@ -543,14 +543,14 @@ jobs:
otool -L ./haxelib

- name: Upload artifact (x64)
if: matrix.os == 'macos-latest'
if: runner.arch == 'X64'
uses: actions/upload-artifact@v4
with:
name: macX64Binaries
path: out

- name: Upload artifact (arm)
if: matrix.os == 'macos-14'
if: runner.arch == 'ARM64'
uses: actions/upload-artifact@v4
with:
name: macArmBinaries
Expand Down Expand Up @@ -689,7 +689,7 @@ jobs:

mac-test:
needs: mac-build-universal
runs-on: macos-latest
runs-on: macos-13
env:
PLATFORM: mac
TEST: ${{matrix.target}}
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/target.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Check pull request target branch
on:
pull_request_target:
types:
- opened
- reopened
- synchronize
- edited
jobs:
check-branches:
runs-on: ubuntu-latest
steps:
- name: Check branches
run: |
if [ ${{ github.base_ref }} != "development" ]; then
echo "Merge requests should target `development`."
exit 1
fi

31 changes: 31 additions & 0 deletions extra/CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
2024-03-04 4.3.4

General improvements:

all : allow @:using with Class and Enum (#11553)
display : expose list of metadata/defines (#11399)

Bugfixes:

all : typedef vs. GADT (#11446)
all : don't double-throw exceptions (#11175)
all : fix some abstract inlining failures (#11526)
all : fix JsonPrinter empty parent class (#11560)
all : dce: clean up operator handling (#11427)
all : analyzer: deal with unreachable block in binops (#11402)
all : analyzer: don't recursively check enum values when const propagating (#11429)
all : analyzer: fix check for inlined purity meta
display : fix errors from parser missing in diagnostics (#8687)
display : fix display services with static extension (#11285)
display : fix display services with safe navigation (#11205)
hl : hlopt rework try-catch control flow (#11581)
hl/c : fix reserved keywords (#11408)

Deprecation / future version handling:

all : don't infer string on concat, when using -D haxe-next (#11318)
all : handle optional arguments with bind, when using -D haxe-next (#11533)
macro : build order vs inheritance, when using -D haxe-next (#11582)
macro : deprecate some API from haxe.macro.Compiler (see #11540)
java/jvm : warn about --java ... -D jvm vs --jvm ...

2023-09-17 4.3.3

General improvements:
Expand Down
4 changes: 2 additions & 2 deletions extra/github-actions/build-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@
otool -L ./haxelib

- name: Upload artifact (x64)
if: matrix.os == 'macos-latest'
if: runner.arch == 'X64'
uses: actions/upload-artifact@v4
with:
name: macX64Binaries
path: out

- name: Upload artifact (arm)
if: matrix.os == 'macos-14'
if: runner.arch == 'ARM64'
uses: actions/upload-artifact@v4
with:
name: macArmBinaries
Expand Down
4 changes: 2 additions & 2 deletions extra/github-actions/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-latest, macos-14]
os: [macos-14, macos-13]
runs-on: ${{ matrix.os }}
env:
PLATFORM: mac
Expand Down Expand Up @@ -393,7 +393,7 @@ jobs:

mac-test:
needs: mac-build-universal
runs-on: macos-latest
runs-on: macos-13
env:
PLATFORM: mac
TEST: ${{matrix.target}}
Expand Down
4 changes: 2 additions & 2 deletions libs/mbedtls/mbedtls.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ external mbedtls_ssl_setup : mbedtls_ssl_context -> mbedtls_ssl_config -> mbedtl
external mbedtls_ssl_write : mbedtls_ssl_context -> bytes -> int -> int -> mbedtls_result = "ml_mbedtls_ssl_write"

external mbedtls_pk_init : unit -> mbedtls_pk_context = "ml_mbedtls_pk_init"
external mbedtls_pk_parse_key : mbedtls_pk_context -> bytes -> string option -> mbedtls_result = "ml_mbedtls_pk_parse_key"
external mbedtls_pk_parse_keyfile : mbedtls_pk_context -> string -> string option -> mbedtls_result = "ml_mbedtls_pk_parse_keyfile"
external mbedtls_pk_parse_key : mbedtls_pk_context -> bytes -> string option -> mbedtls_ctr_drbg_context -> mbedtls_result = "ml_mbedtls_pk_parse_key"
external mbedtls_pk_parse_keyfile : mbedtls_pk_context -> string -> string option -> mbedtls_ctr_drbg_context -> mbedtls_result = "ml_mbedtls_pk_parse_keyfile"
external mbedtls_pk_parse_public_keyfile : mbedtls_pk_context -> string -> mbedtls_result = "ml_mbedtls_pk_parse_public_keyfile"
external mbedtls_pk_parse_public_key : mbedtls_pk_context -> bytes -> mbedtls_result = "ml_mbedtls_pk_parse_public_key"

Expand Down
103 changes: 51 additions & 52 deletions libs/mbedtls/mbedtls_stubs.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <ctype.h>
#include <string.h>
#include <stdio.h>

Expand All @@ -18,13 +17,10 @@
#include <caml/callback.h>
#include <caml/custom.h>

#include "mbedtls/debug.h"
#include "mbedtls/error.h"
#include "mbedtls/config.h"
#include "mbedtls/ssl.h"
#include "mbedtls/entropy.h"
#include "mbedtls/ctr_drbg.h"
#include "mbedtls/certs.h"
#include "mbedtls/oid.h"

#define PVoid_val(v) (*((void**) Data_custom_val(v)))
Expand Down Expand Up @@ -84,7 +80,7 @@ CAMLprim value ml_mbedtls_ctr_drbg_init(void) {

CAMLprim value ml_mbedtls_ctr_drbg_random(value p_rng, value output, value output_len) {
CAMLparam3(p_rng, output, output_len);
CAMLreturn(Val_int(mbedtls_ctr_drbg_random(CtrDrbg_val(p_rng), String_val(output), Int_val(output_len))));
CAMLreturn(Val_int(mbedtls_ctr_drbg_random(CtrDrbg_val(p_rng), Bytes_val(output), Int_val(output_len))));
}

CAMLprim value ml_mbedtls_ctr_drbg_seed(value ctx, value p_entropy, value custom) {
Expand Down Expand Up @@ -124,7 +120,7 @@ CAMLprim value ml_mbedtls_entropy_init(void) {

CAMLprim value ml_mbedtls_entropy_func(value data, value output, value len) {
CAMLparam3(data, output, len);
CAMLreturn(Val_int(mbedtls_entropy_func(PVoid_val(data), String_val(output), Int_val(len))));
CAMLreturn(Val_int(mbedtls_entropy_func(PVoid_val(data), Bytes_val(output), Int_val(len))));
}

// Certificate
Expand Down Expand Up @@ -171,7 +167,7 @@ CAMLprim value ml_mbedtls_x509_next(value chain) {

CAMLprim value ml_mbedtls_x509_crt_parse(value chain, value bytes) {
CAMLparam2(chain, bytes);
const char* buf = String_val(bytes);
const unsigned char* buf = Bytes_val(bytes);
int len = caml_string_length(bytes);
CAMLreturn(Val_int(mbedtls_x509_crt_parse(X509Crt_val(chain), buf, len + 1)));
}
Expand All @@ -191,16 +187,19 @@ CAMLprim value ml_mbedtls_x509_crt_parse_path(value chain, value path) {
value caml_string_of_asn1_buf(mbedtls_asn1_buf* dat) {
CAMLparam0();
CAMLlocal1(s);
s = caml_alloc_string(dat->len);
memcpy(String_val(s), dat->p, dat->len);
s = caml_alloc_initialized_string(dat->len, (const char *)dat->p);
CAMLreturn(s);
}

CAMLprim value hx_cert_get_alt_names(value chain) {
CAMLparam1(chain);
CAMLlocal1(obj);
mbedtls_x509_crt* cert = X509Crt_val(chain);
if (cert->ext_types & MBEDTLS_X509_EXT_SUBJECT_ALT_NAME == 0 || &cert->subject_alt_names == NULL) {
#if MBEDTLS_VERSION_MAJOR >= 3
if (!mbedtls_x509_crt_has_ext_type(cert, MBEDTLS_X509_EXT_SUBJECT_ALT_NAME)) {
#else
if ((cert->ext_types & MBEDTLS_X509_EXT_SUBJECT_ALT_NAME) == 0) {
#endif
obj = Atom(0);
} else {
mbedtls_asn1_sequence* cur = &cert->subject_alt_names;
Expand Down Expand Up @@ -366,29 +365,39 @@ CAMLprim value ml_mbedtls_pk_init(void) {
CAMLreturn(obj);
}

CAMLprim value ml_mbedtls_pk_parse_key(value ctx, value key, value password) {
CAMLparam3(ctx, key, password);
const char* pwd = NULL;
CAMLprim value ml_mbedtls_pk_parse_key(value ctx, value key, value password, value rng) {
CAMLparam4(ctx, key, password, rng);
const unsigned char* pwd = NULL;
size_t pwdlen = 0;
if (password != Val_none) {
pwd = String_val(Field(password, 0));
pwd = Bytes_val(Field(password, 0));
pwdlen = caml_string_length(Field(password, 0));
}
CAMLreturn(mbedtls_pk_parse_key(PkContext_val(ctx), String_val(key), caml_string_length(key) + 1, pwd, pwdlen));
#if MBEDTLS_VERSION_MAJOR >= 3
mbedtls_ctr_drbg_context *ctr_drbg = CtrDrbg_val(rng);
CAMLreturn(mbedtls_pk_parse_key(PkContext_val(ctx), Bytes_val(key), caml_string_length(key) + 1, pwd, pwdlen, mbedtls_ctr_drbg_random, NULL));
#else
CAMLreturn(mbedtls_pk_parse_key(PkContext_val(ctx), Bytes_val(key), caml_string_length(key) + 1, pwd, pwdlen));
#endif
}

CAMLprim value ml_mbedtls_pk_parse_keyfile(value ctx, value path, value password) {
CAMLparam3(ctx, path, password);
CAMLprim value ml_mbedtls_pk_parse_keyfile(value ctx, value path, value password, value rng) {
CAMLparam4(ctx, path, password, rng);
const char* pwd = NULL;
if (password != Val_none) {
pwd = String_val(Field(password, 0));
}
#if MBEDTLS_VERSION_MAJOR >= 3
mbedtls_ctr_drbg_context *ctr_drbg = CtrDrbg_val(rng);
CAMLreturn(mbedtls_pk_parse_keyfile(PkContext_val(ctx), String_val(path), pwd, mbedtls_ctr_drbg_random, ctr_drbg));
#else
CAMLreturn(mbedtls_pk_parse_keyfile(PkContext_val(ctx), String_val(path), pwd));
#endif
}

CAMLprim value ml_mbedtls_pk_parse_public_key(value ctx, value key) {
CAMLparam2(ctx, key);
CAMLreturn(mbedtls_pk_parse_public_key(PkContext_val(ctx), String_val(key), caml_string_length(key) + 1));
CAMLreturn(mbedtls_pk_parse_public_key(PkContext_val(ctx), Bytes_val(key), caml_string_length(key) + 1));
}

CAMLprim value ml_mbedtls_pk_parse_public_keyfile(value ctx, value path) {
Expand Down Expand Up @@ -446,23 +455,22 @@ CAMLprim value ml_mbedtls_ssl_handshake(value ssl) {

CAMLprim value ml_mbedtls_ssl_read(value ssl, value buf, value pos, value len) {
CAMLparam4(ssl, buf, pos, len);
CAMLreturn(Val_int(mbedtls_ssl_read(SslContext_val(ssl), String_val(buf) + Int_val(pos), Int_val(len))));
CAMLreturn(Val_int(mbedtls_ssl_read(SslContext_val(ssl), Bytes_val(buf) + Int_val(pos), Int_val(len))));
}

static int bio_write_cb(void* ctx, const unsigned char* buf, size_t len) {
CAMLparam0();
CAMLlocal3(r, s, vctx);
vctx = (value)ctx;
s = caml_alloc_string(len);
memcpy(String_val(s), buf, len);
vctx = *(value*)ctx;
s = caml_alloc_initialized_string(len, (const char*)buf);
r = caml_callback2(Field(vctx, 1), Field(vctx, 0), s);
CAMLreturn(Int_val(r));
}

static int bio_read_cb(void* ctx, unsigned char* buf, size_t len) {
CAMLparam0();
CAMLlocal3(r, s, vctx);
vctx = (value)ctx;
vctx = *(value*)ctx;
s = caml_alloc_string(len);
r = caml_callback2(Field(vctx, 2), Field(vctx, 0), s);
memcpy(buf, String_val(s), len);
Expand All @@ -476,7 +484,11 @@ CAMLprim value ml_mbedtls_ssl_set_bio(value ssl, value p_bio, value f_send, valu
Store_field(ctx, 0, p_bio);
Store_field(ctx, 1, f_send);
Store_field(ctx, 2, f_recv);
mbedtls_ssl_set_bio(SslContext_val(ssl), (void*)ctx, bio_write_cb, bio_read_cb, NULL);
// TODO: this allocation is leaked
value *location = malloc(sizeof(value));
*location = ctx;
caml_register_generational_global_root(location);
mbedtls_ssl_set_bio(SslContext_val(ssl), (void*)location, bio_write_cb, bio_read_cb, NULL);
CAMLreturn(Val_unit);
}

Expand All @@ -492,7 +504,7 @@ CAMLprim value ml_mbedtls_ssl_setup(value ssl, value conf) {

CAMLprim value ml_mbedtls_ssl_write(value ssl, value buf, value pos, value len) {
CAMLparam4(ssl, buf, pos, len);
CAMLreturn(Val_int(mbedtls_ssl_write(SslContext_val(ssl), String_val(buf) + Int_val(pos), Int_val(len))));
CAMLreturn(Val_int(mbedtls_ssl_write(SslContext_val(ssl), Bytes_val(buf) + Int_val(pos), Int_val(len))));
}

// glue
Expand Down Expand Up @@ -520,36 +532,23 @@ CAMLprim value hx_cert_load_defaults(value certificate) {
#endif

#ifdef __APPLE__
CFMutableDictionaryRef search;
CFArrayRef result;
SecKeychainRef keychain;
SecCertificateRef item;
CFDataRef dat;
// Load keychain
if (SecKeychainOpen("/System/Library/Keychains/SystemRootCertificates.keychain", &keychain) == errSecSuccess) {
// Search for certificates
search = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
CFDictionarySetValue(search, kSecClass, kSecClassCertificate);
CFDictionarySetValue(search, kSecMatchLimit, kSecMatchLimitAll);
CFDictionarySetValue(search, kSecReturnRef, kCFBooleanTrue);
CFDictionarySetValue(search, kSecMatchSearchList, CFArrayCreate(NULL, (const void **)&keychain, 1, NULL));
if (SecItemCopyMatching(search, (CFTypeRef *)&result) == errSecSuccess) {
CFIndex n = CFArrayGetCount(result);
for (CFIndex i = 0; i < n; i++) {
item = (SecCertificateRef)CFArrayGetValueAtIndex(result, i);

// Get certificate in DER format
dat = SecCertificateCopyData(item);
if (dat) {
r = mbedtls_x509_crt_parse_der(chain, (unsigned char *)CFDataGetBytePtr(dat), CFDataGetLength(dat));
CFRelease(dat);
if (r != 0) {
CAMLreturn(Val_int(r));
}
CFArrayRef certs;
if (SecTrustCopyAnchorCertificates(&certs) == errSecSuccess) {
CFIndex count = CFArrayGetCount(certs);
for(CFIndex i = 0; i < count; i++) {
SecCertificateRef item = (SecCertificateRef)CFArrayGetValueAtIndex(certs, i);

// Get certificate in DER format
CFDataRef data = SecCertificateCopyData(item);
if(data) {
r = mbedtls_x509_crt_parse_der(chain, (unsigned char *)CFDataGetBytePtr(data), CFDataGetLength(data));
CFRelease(data);
if (r != 0) {
CAMLreturn(Val_int(r));
}
}
}
CFRelease(keychain);
CFRelease(certs);
}
#endif

Expand Down
5 changes: 5 additions & 0 deletions src-json/define.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@
"doc": "Record per-method execution times in macro/interp mode. Implies eval-stack.",
"platforms": ["eval"]
},
{
"name": "FailFast",
"define": "fail-fast",
"doc": "Abort compilation when first error occurs."
},
{
"name": "FilterTimes",
"define": "filter-times",
Expand Down
12 changes: 2 additions & 10 deletions src/codegen/javaModern.ml
Original file line number Diff line number Diff line change
Expand Up @@ -754,11 +754,7 @@ module Converter = struct
tp

let convert_enum (jc : jclass) (file : string) =
let p = {
pfile = file;
pmin = 0;
pmax = 0
} in
let p = file_pos file in
let meta = ref [] in
let add_meta m = meta := m :: !meta in
let data = ref [] in
Expand Down Expand Up @@ -920,11 +916,7 @@ module Converter = struct
cff

let convert_class ctx (jc : jclass) (file : string) =
let p = {
pfile = file;
pmin = 0;
pmax = 0
} in
let p = file_pos file in
let flags = ref [HExtern] in
let meta = ref [] in
let add_flag f = flags := f :: !flags in
Expand Down
Loading

0 comments on commit 70b4d3c

Please sign in to comment.