Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous small fixes #3643

Merged
merged 5 commits into from
Aug 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .lgtm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
path_classifiers:
thirdparty:
- /tools/amalgamate
- /tools/cpplint
falbrechtskirchinger marked this conversation as resolved.
Show resolved Hide resolved
33 changes: 16 additions & 17 deletions tests/src/unit-readme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,10 @@ TEST_CASE("README" * doctest::skip())
json j = "{ \"happy\": true, \"pi\": 3.141 }"_json; // NOLINT(modernize-raw-string-literal)

// or even nicer with a raw string literal
auto j2 = R"(
{
"happy": true,
"pi": 3.141
}
)"_json;
auto j2 = R"({
"happy": true,
"pi": 3.141
})"_json;

// or explicitly
auto j3 = json::parse(R"({"happy": true, "pi": 3.141})");
Expand Down Expand Up @@ -160,10 +158,10 @@ TEST_CASE("README" * doctest::skip())
CHECK(foo == true);

// other stuff
j.size(); // 3 entries
j.empty(); // false
j.type(); // json::value_t::array
j.clear(); // the array is empty again
CHECK(j.size() == 3); // 3 entries
nlohmann marked this conversation as resolved.
Show resolved Hide resolved
CHECK_FALSE(j.empty()); // false
CHECK(j.type() == json::value_t::array); // json::value_t::array
falbrechtskirchinger marked this conversation as resolved.
Show resolved Hide resolved
j.clear(); // the array is empty again

// create an object
json o;
Expand All @@ -172,6 +170,7 @@ TEST_CASE("README" * doctest::skip())
o["baz"] = 3.141;

// find an entry
CHECK(o.find("foo") != o.end());
if (o.find("foo") != o.end())
{
// there is an entry with key "foo"
Expand Down Expand Up @@ -266,20 +265,20 @@ TEST_CASE("README" * doctest::skip())
{
// a JSON value
json j_original = R"({
"baz": ["one", "two", "three"],
"foo": "bar"
})"_json;
"baz": ["one", "two", "three"],
"foo": "bar"
})"_json;

// access members with a JSON pointer (RFC 6901)
j_original["/baz/1"_json_pointer];
// "two"

// a JSON patch (RFC 6902)
json j_patch = R"([
{ "op": "replace", "path": "/baz", "value": "boo" },
{ "op": "add", "path": "/hello", "value": ["world"] },
{ "op": "remove", "path": "/foo"}
])"_json;
{ "op": "replace", "path": "/baz", "value": "boo" },
{ "op": "add", "path": "/hello", "value": ["world"] },
{ "op": "remove", "path": "/foo"}
])"_json;

// apply the patch
json j_result = j_original.patch(j_patch);
Expand Down
14 changes: 7 additions & 7 deletions tools/serve_header/serve_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def stop(self):
self.observer.stop()
self.observer.join()

class HeaderRequestHandler(SimpleHTTPRequestHandler):
class HeaderRequestHandler(SimpleHTTPRequestHandler): # lgtm[py/missing-call-to-init]
nlohmann marked this conversation as resolved.
Show resolved Hide resolved
def __init__(self, request, client_address, server):
"""."""
self.worktrees = server.worktrees
Expand Down Expand Up @@ -388,11 +388,11 @@ def server_bind(self):
if https.get('enabled', True):
cert_file = https.get('cert_file', 'localhost.pem')
key_file = https.get('key_file', 'localhost-key.pem')
ssl.minimum_version = ssl.TLSVersion.TLSv1_3
ssl.maximum_version = ssl.TLSVersion.MAXIMUM_SUPPORTED
httpd.socket = ssl.wrap_socket(httpd.socket,
certfile=cert_file, keyfile=key_file,
server_side=True, ssl_version=ssl.PROTOCOL_TLS)
ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ssl_ctx.minimum_version = ssl.TLSVersion.TLSv1_2
ssl_ctx.maximum_version = ssl.TLSVersion.MAXIMUM_SUPPORTED
ssl_ctx.load_cert_chain(cert_file, key_file)
httpd.socket = ssl_ctx.wrap_socket(httpd.socket, server_side=True)

Check notice

Code scanning

Use of insecure SSL/TLS version

Insecure SSL/TLS protocol version TLSv1 allowed by [call to ssl.create_default_context](1) Insecure SSL/TLS protocol version TLSv1_1 allowed by [call to ssl.create_default_context](1)
scheme = 'HTTPS'
host, port = httpd.socket.getsockname()[:2]
log.info(f'serving {scheme} on {host} port {port}')
Expand All @@ -402,8 +402,8 @@ def server_bind(self):
except KeyboardInterrupt:
log.info('exiting')
except Exception:
log.exception('an error occurred:')
ec = 1
log.exception('an error occurred:')
finally:
if worktrees is not None:
worktrees.stop()
Expand Down