Compare commits

..

1 Commits

Author SHA1 Message Date
Marcus Dreier
bd40949c29
Merge 149e52f2c5 into 347054b329 2024-01-11 01:05:25 -07:00
15 changed files with 7 additions and 259 deletions

View File

@ -1,6 +0,0 @@
#!/usr/bin/env bash
sudo apt-get install check ninja-build doxygen
cp contrib/examples/example_app/lwipcfg.h.ci contrib/examples/example_app/lwipcfg.h
make -C contrib/ports/unix/check
mkdir build && cd build && cmake .. -G Ninja && cmake --build .

View File

@ -1,126 +0,0 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
# push:
# branches: [ "main", "master" ]
schedule:
- cron: '0 0 * * *'
pull_request:
branches: '*'
jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-20.04' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
queries: security-and-quality
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
#- name: Autobuild
# uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
- run: |
./.github/workflows/codeql-buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
upload: false
id: step1
# Filter out rules with low severity or high false positve rate
# Also filter out warnings in third-party code
- name: Filter out unwanted errors and warnings
uses: advanced-security/filter-sarif@v1
with:
patterns: |
-**:cpp/path-injection
-**:cpp/world-writable-file-creation
-**:cpp/poorly-documented-function
-**:cpp/potentially-dangerous-function
-**:cpp/use-of-goto
-**:cpp/integer-multiplication-cast-to-long
-**:cpp/comparison-with-wider-type
-**:cpp/leap-year/*
-**:cpp/ambiguously-signed-bit-field
-**:cpp/suspicious-pointer-scaling
-**:cpp/suspicious-pointer-scaling-void
-**:cpp/unsigned-comparison-zero
-**/cmake*/Modules/**
input: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
- name: Upload CodeQL results to code scanning
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.step1.outputs.sarif-output }}
category: "/language:${{matrix.language}}"
- name: Upload CodeQL results as an artifact
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: codeql-results
path: ${{ steps.step1.outputs.sarif-output }}
retention-days: 5
- name: Fail if an error is found
run: |
./.github/workflows/fail_on_error.py \
${{ steps.step1.outputs.sarif-output }}/cpp.sarif

View File

@ -1,34 +0,0 @@
#!/usr/bin/env python3
import json
import sys
# Return whether SARIF file contains error-level results
def codeql_sarif_contain_error(filename):
with open(filename, 'r') as f:
s = json.load(f)
for run in s.get('runs', []):
rules_metadata = run['tool']['driver']['rules']
if not rules_metadata:
rules_metadata = run['tool']['extensions'][0]['rules']
for res in run.get('results', []):
if 'ruleIndex' in res:
rule_index = res['ruleIndex']
elif 'rule' in res and 'index' in res['rule']:
rule_index = res['rule']['index']
else:
continue
try:
rule_level = rules_metadata[rule_index]['defaultConfiguration']['level']
except IndexError as e:
print(e, rule_index, len(rules_metadata))
else:
if rule_level == 'error':
return True
return False
if __name__ == "__main__":
if codeql_sarif_contain_error(sys.argv[1]):
sys.exit(1)

View File

@ -52,10 +52,6 @@
#define LWIP_TIMEVAL_PRIVATE 0
#include <sys/time.h>
#ifdef __cplusplus
extern "C" {
#endif
#define LWIP_ERRNO_INCLUDE <errno.h>
#if defined(LWIP_UNIX_LINUX) || defined(LWIP_UNIX_HURD) || defined(LWIP_UNIX_KFREEBSD)
@ -90,8 +86,4 @@ typedef struct sio_status_s sio_status_t;
typedef unsigned int sys_prot_t;
#ifdef __cplusplus
}
#endif
#endif /* LWIP_ARCH_CC_H */

View File

@ -34,10 +34,6 @@
#include <sys/times.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef PERF
#define PERF_START { \
unsigned long __c1l, __c1h, __c2l, __c2h; \
@ -64,8 +60,4 @@ void perf_print_times(struct tms *start, struct tms *end, char *key);
void perf_init(char *fname);
#ifdef __cplusplus
}
#endif
#endif /* LWIP_ARCH_PERF_H */

View File

@ -32,10 +32,6 @@
#ifndef LWIP_ARCH_SYS_ARCH_H
#define LWIP_ARCH_SYS_ARCH_H
#ifdef __cplusplus
extern "C" {
#endif
#define SYS_MBOX_NULL NULL
#define SYS_SEM_NULL NULL
@ -91,8 +87,4 @@ void sys_unlock_tcpip_core(void);
#define UNLOCK_TCPIP_CORE() sys_unlock_tcpip_core()
#endif
#ifdef __cplusplus
}
#endif
#endif /* LWIP_ARCH_SYS_ARCH_H */

View File

@ -3,10 +3,6 @@
#include "lwip/sys.h"
#ifdef __cplusplus
extern "C" {
#endif
/** How many bytes in fifo */
#define FIFOSIZE 2048
@ -54,9 +50,5 @@ void fifoPut(fifo_t * fifo, int fd);
*/
void fifoInit(fifo_t * fifo);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -2,10 +2,6 @@
#ifndef LWIP_LIST_H
#define LWIP_LIST_H
#ifdef __cplusplus
extern "C" {
#endif
struct elem;
struct list {
@ -27,8 +23,4 @@ void list_delete(struct list *list);
int list_remove(struct list *list, void *elem);
void list_map(struct list *list, void (* func)(void *arg));
#ifdef __cplusplus
}
#endif
#endif

View File

@ -34,14 +34,6 @@
#include "lwip/netif.h"
#ifdef __cplusplus
extern "C" {
#endif
err_t pcapif_init(struct netif *netif);
#ifdef __cplusplus
}
#endif
#endif /* LWIP_PCAPIF_H */

View File

@ -6,10 +6,6 @@
#include "netif/fifo.h"
/*#include "netif/pppif.h"*/
#ifdef __cplusplus
extern "C" {
#endif
struct sio_status_s {
int fd;
fifo_t myfifo;
@ -60,9 +56,5 @@ void sio_flush( sio_status_t * siostat );
*/
void sio_change_baud( sioBaudrates baud, sio_status_t * siostat );
#ifdef __cplusplus
}
#endif
#endif

View File

@ -34,18 +34,10 @@
#include "lwip/netif.h"
#ifdef __cplusplus
extern "C" {
#endif
err_t tapif_init(struct netif *netif);
void tapif_poll(struct netif *netif);
#if NO_SYS
int tapif_select(struct netif *netif);
#endif /* NO_SYS */
#ifdef __cplusplus
}
#endif
#endif /* LWIP_TAPIF_H */

View File

@ -34,18 +34,10 @@
#include "lwip/netif.h"
#ifdef __cplusplus
extern "C" {
#endif
err_t vdeif_init(struct netif *netif);
void vdeif_poll(struct netif *netif);
#if NO_SYS
int vdeif_select(struct netif *netif);
#endif /* NO_SYS */
#ifdef __cplusplus
}
#endif
#endif /* LWIP_VDEIF_H */

View File

@ -40,7 +40,6 @@
#if LWIP_DNS && LWIP_SOCKET
#include "lwip/err.h"
#include "lwip/errno.h"
#include "lwip/mem.h"
#include "lwip/memp.h"
#include "lwip/ip_addr.h"
@ -383,9 +382,7 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
/* set up sockaddr */
inet6_addr_from_ip6addr(&sa6->sin6_addr, ip_2_ip6(&addr));
sa6->sin6_family = AF_INET6;
#if LWIP_SOCKET_HAVE_SA_LEN
sa6->sin6_len = sizeof(struct sockaddr_in6);
#endif /* LWIP_SOCKET_HAVE_SA_LEN */
sa6->sin6_port = lwip_htons((u16_t)port_nr);
sa6->sin6_scope_id = ip6_addr_zone(ip_2_ip6(&addr));
ai->ai_family = AF_INET6;
@ -396,9 +393,7 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
/* set up sockaddr */
inet_addr_from_ip4addr(&sa4->sin_addr, ip_2_ip4(&addr));
sa4->sin_family = AF_INET;
#if LWIP_SOCKET_HAVE_SA_LEN
sa4->sin_len = sizeof(struct sockaddr_in);
#endif /* LWIP_SOCKET_HAVE_SA_LEN */
sa4->sin_port = lwip_htons((u16_t)port_nr);
ai->ai_family = AF_INET;
#endif /* LWIP_IPV4 */

View File

@ -68,20 +68,11 @@ sys_mutex_t lock_tcpip_core;
static void tcpip_thread_handle_msg(struct tcpip_msg *msg);
#if !LWIP_TIMERS
/** Wait for a message with timers disabled (e.g. pass a timer-check trigger into tcpip_thread) */
static void
tcpip_mbox_fetch(sys_mbox_t* mbox, void** msg)
{
LWIP_ASSERT_CORE_LOCKED();
UNLOCK_TCPIP_CORE();
sys_mbox_fetch(mbox, msg);
LOCK_TCPIP_CORE();
}
/* wait for a message with timers disabled (e.g. pass a timer-check trigger into tcpip_thread) */
#define TCPIP_MBOX_FETCH(mbox, msg) sys_mbox_fetch(mbox, msg)
#else /* !LWIP_TIMERS */
/* wait for a message, timeouts are processed while waiting */
#define TCPIP_MBOX_FETCH(mbox, msg) tcpip_timeouts_mbox_fetch(mbox, msg)
/**
* Wait (forever) for a message to arrive in an mbox.
* While waiting, timeouts are processed.
@ -90,7 +81,7 @@ tcpip_mbox_fetch(sys_mbox_t* mbox, void** msg)
* @param msg the place to store the message
*/
static void
tcpip_mbox_fetch(sys_mbox_t *mbox, void **msg)
tcpip_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg)
{
u32_t sleeptime, res;
@ -148,7 +139,7 @@ tcpip_thread(void *arg)
while (1) { /* MAIN Loop */
LWIP_TCPIP_THREAD_ALIVE();
/* wait for a message, timeouts are processed while waiting */
tcpip_mbox_fetch(&tcpip_mbox, (void **)&msg);
TCPIP_MBOX_FETCH(&tcpip_mbox, (void **)&msg);
if (msg == NULL) {
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: invalid message: NULL\n"));
LWIP_ASSERT("tcpip_thread: invalid message", 0);

View File

@ -21,7 +21,7 @@ while($file = <FILES>) {
print(HEADER "HTTP/1.0 200 OK\r\n");
}
print(HEADER "Server: lwIP/pre-0.6 (http://www.sics.se/~adam/lwip/)\r\n");
if($file =~ /\.s?html?$/) {
if($file =~ /\.html$/) {
print(HEADER "Content-type: text/html\r\n");
} elsif($file =~ /\.gif$/) {
print(HEADER "Content-type: image/gif\r\n");