Skip to content

Commit 41ea1d4

Browse files
authored
Merge pull request #120 from oracle/workflow-updates
2 parents 23cc328 + 12ef046 commit 41ea1d4

File tree

12 files changed

+116
-25
lines changed

12 files changed

+116
-25
lines changed

.github/workflows/static.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
name: Static analysis
3+
4+
on: [push, pull_request, workflow_dispatch]
5+
6+
jobs:
7+
cppcheck:
8+
runs-on: ubuntu-latest
9+
permissions: read-all
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Install build dependencies
15+
run: |
16+
sudo apt-get update
17+
sudo apt-get -y install \
18+
build-essential \
19+
autoconf \
20+
automake \
21+
gnutls-dev \
22+
libkeyutils-dev \
23+
libnl-3-dev \
24+
libnl-genl-3-dev \
25+
libglib2.0-dev
26+
27+
- name: Install tools
28+
run: |
29+
sudo apt-get install -y bear cppcheck
30+
31+
- name: Configure
32+
run: |
33+
./autogen.sh
34+
./configure --with-systemd
35+
36+
- name: Generate compile commands
37+
run: |
38+
bear -- make
39+
40+
- name: Run Cppcheck
41+
run: |
42+
echo "::group::Cppcheck Analysis"
43+
cppcheck --enable=all -I. \
44+
--suppress=missingIncludeSystem \
45+
--suppress=unusedFunction \
46+
src/
47+
echo "::endgroup::"
48+
49+
lizard:
50+
runs-on: ubuntu-latest
51+
permissions: read-all
52+
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- name: Install build dependencies
57+
run: |
58+
sudo apt-get update
59+
sudo apt-get -y install \
60+
build-essential \
61+
autoconf \
62+
automake \
63+
gnutls-dev \
64+
libkeyutils-dev \
65+
libnl-3-dev \
66+
libnl-genl-3-dev \
67+
libglib2.0-dev
68+
69+
- name: Install tools
70+
run: |
71+
pip3 install lizard bandit[toml]
72+
73+
- name: Configure
74+
run: |
75+
./autogen.sh
76+
./configure --with-systemd
77+
78+
- name: Run Lizard Complexity Analysis
79+
run: |
80+
echo "::group::Complexity Analysis"
81+
lizard --CCN 15 src/ || true
82+
echo "::endgroup::"

src/tlshd/client.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* 02110-1301, USA.
2121
*/
2222

23-
#include "config.h"
23+
#include <config.h>
2424

2525
#include <sys/types.h>
2626
#include <sys/socket.h>
@@ -171,14 +171,16 @@ static void tlshd_x509_log_issuers(const gnutls_datum_t *req_ca_rdn, int nreqs)
171171
{
172172
char issuer_dn[256];
173173
size_t len;
174-
int i, ret;
174+
int i;
175175

176176
if (nreqs < 1)
177177
return;
178178

179179
tlshd_log_debug("Server's trusted authorities:");
180180

181181
for (i = 0; i < nreqs; i++) {
182+
int ret;
183+
182184
len = sizeof(issuer_dn);
183185
ret = gnutls_x509_rdn_get(&req_ca_rdn[i], issuer_dn, &len);
184186
if (ret >= 0)

src/tlshd/config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* 02110-1301, USA.
1919
*/
2020

21-
#include "config.h"
21+
#include <config.h>
2222

2323
#include <sys/types.h>
2424
#include <sys/socket.h>

src/tlshd/handshake.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* 02110-1301, USA.
2020
*/
2121

22-
#include "config.h"
22+
#include <config.h>
2323

2424
#include <sys/types.h>
2525
#include <sys/socket.h>
@@ -64,7 +64,7 @@ static void tlshd_save_nagle(gnutls_session_t session, int *saved)
6464
IPPROTO_TCP, TCP_NODELAY, saved, &len);
6565
if (ret < 0) {
6666
tlshd_log_perror("getsockopt (NODELAY)");
67-
saved = 0;
67+
*saved = 0;
6868
return;
6969
}
7070

src/tlshd/keyring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* 02110-1301, USA.
1919
*/
2020

21-
#include "config.h"
21+
#include <config.h>
2222

2323
#include <sys/types.h>
2424
#include <sys/socket.h>

src/tlshd/ktls.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* 02110-1301, USA.
2020
*/
2121

22-
#include "config.h"
22+
#include <config.h>
2323

2424
#include <sys/types.h>
2525
#include <sys/socket.h>
@@ -540,7 +540,7 @@ int tlshd_gnutls_priority_init(void)
540540
* Returns GNUTLS_E_SUCCESS on success, otherwise an error code.
541541
*/
542542
int tlshd_gnutls_priority_set(gnutls_session_t session,
543-
struct tlshd_handshake_parms *parms,
543+
const struct tlshd_handshake_parms *parms,
544544
unsigned int psk_len)
545545
{
546546
gnutls_priority_t priority = tlshd_gnutls_priority_x509;

src/tlshd/log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* 02110-1301, USA.
1919
*/
2020

21-
#include "config.h"
21+
#include <config.h>
2222

2323
#include <stdbool.h>
2424
#include <unistd.h>

src/tlshd/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* 02110-1301, USA.
2020
*/
2121

22-
#include "config.h"
22+
#include <config.h>
2323

2424
#include <sys/types.h>
2525
#include <sys/socket.h>
@@ -56,7 +56,7 @@ static const struct option longopts[] = {
5656
{ NULL, 0, NULL, 0 }
5757
};
5858

59-
static void usage(char *progname)
59+
static void usage(const char *progname)
6060
{
6161
fprintf(stderr, "usage: %s [-chsv]\n", progname);
6262
}

src/tlshd/netlink.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* 02110-1301, USA.
1919
*/
2020

21-
#include "config.h"
21+
#include <config.h>
2222

2323
#include <sys/types.h>
2424
#include <sys/stat.h>
@@ -283,8 +283,8 @@ static int tlshd_genl_valid_handler(struct nl_msg *msg, void *arg)
283283
struct tlshd_handshake_parms *parms = arg;
284284
struct sockaddr_storage addr;
285285
struct sockaddr *sap = NULL;
286+
const char *peername = NULL;
286287
socklen_t salen, optlen;
287-
char *peername = NULL;
288288
int err;
289289

290290
tlshd_log_debug("Parsing a valid netlink message\n");
@@ -390,8 +390,8 @@ static const struct tlshd_handshake_parms tlshd_default_handshake_parms = {
390390
*/
391391
int tlshd_genl_get_handshake_parms(struct tlshd_handshake_parms *parms)
392392
{
393+
const struct nlmsghdr *hdr;
393394
int family_id, err, ret;
394-
struct nlmsghdr *hdr;
395395
struct nl_sock *nls;
396396
struct nl_msg *msg;
397397

@@ -480,9 +480,10 @@ static int tlshd_genl_put_remote_peerids(struct nl_msg *msg,
480480
{
481481
key_serial_t peerid;
482482
guint i;
483-
int err;
484483

485484
for (i = 0; i < parms->remote_peerids->len; i++) {
485+
int err;
486+
486487
peerid = g_array_index(parms->remote_peerids, key_serial_t, i);
487488
err = nla_put_s32(msg, HANDSHAKE_A_DONE_REMOTE_AUTH, peerid);
488489
if (err < 0) {
@@ -500,7 +501,7 @@ static int tlshd_genl_put_remote_peerids(struct nl_msg *msg,
500501
*/
501502
void tlshd_genl_done(struct tlshd_handshake_parms *parms)
502503
{
503-
struct nlmsghdr *hdr;
504+
const struct nlmsghdr *hdr;
504505
struct nl_sock *nls;
505506
struct nl_msg *msg;
506507
int family_id, err;

src/tlshd/quic.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* 02110-1301, USA.
1919
*/
2020

21+
#include <config.h>
22+
2123
#include <gnutls/abstract.h>
2224
#include <sys/socket.h>
2325
#include <linux/tls.h>
@@ -26,7 +28,6 @@
2628
#include <unistd.h>
2729
#include <glib.h>
2830

29-
#include "config.h"
3031
#include "tlshd.h"
3132

3233
#ifdef HAVE_GNUTLS_QUIC
@@ -106,7 +107,7 @@ static int quic_secret_func(gnutls_session_t session, gnutls_record_encryption_l
106107
struct tlshd_quic_conn *conn = gnutls_session_get_ptr(session);
107108
gnutls_cipher_algorithm_t type = gnutls_cipher_get(session);
108109
struct quic_crypto_secret secret = {};
109-
int sockfd, ret, len = sizeof(secret);
110+
int sockfd, len = sizeof(secret);
110111

111112
if (conn->completed)
112113
return 0;
@@ -134,6 +135,8 @@ static int quic_secret_func(gnutls_session_t session, gnutls_record_encryption_l
134135
}
135136
if (secret.level == QUIC_CRYPTO_APP) {
136137
if (conn->is_serv) {
138+
int ret;
139+
137140
ret = gnutls_session_ticket_send(session, 1, 0);
138141
if (ret) {
139142
tlshd_log_gnutls_error(ret);
@@ -383,13 +386,14 @@ static int quic_handshake_recvmsg(int sockfd, struct tlshd_quic_msg *msg)
383386
return ret;
384387
}
385388

386-
static int quic_handshake_completed(struct tlshd_quic_conn *conn)
389+
static int quic_handshake_completed(const struct tlshd_quic_conn *conn)
387390
{
388391
return conn->completed || conn->errcode;
389392
}
390393

391-
static int quic_handshake_crypto_data(struct tlshd_quic_conn *conn, uint8_t level,
392-
const uint8_t *data, size_t datalen)
394+
static int quic_handshake_crypto_data(const struct tlshd_quic_conn *conn,
395+
uint8_t level, const uint8_t *data,
396+
size_t datalen)
393397
{
394398
gnutls_session_t session = conn->session;
395399
int ret;

0 commit comments

Comments
 (0)