diff --git a/.github/config/codeql.yml b/.github/config/codeql.yml new file mode 100644 index 00000000..d1492f7c --- /dev/null +++ b/.github/config/codeql.yml @@ -0,0 +1,4 @@ +name: "CodeQL config" +paths-ignore: + - 'dependencies/external/' + - 'assets/webconfig/js/lib' diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000..a2c530b1 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,76 @@ +name: "CodeQL" + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + schedule: + - cron: "36 18 * * 4" + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ python, javascript, cpp ] + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Install Packages (cpp) + if: ${{ matrix.language == 'cpp' }} + run: | + sudo apt-get update + sudo apt-get install --yes git cmake build-essential qtbase5-dev libqt5serialport5-dev libqt5sql5-sqlite libqt5svg5-dev libqt5x11extras5-dev libusb-1.0-0-dev python3-dev libcec-dev libxcb-image0-dev libxcb-util0-dev libxcb-shm0-dev libxcb-render0-dev libxcb-randr0-dev libxrandr-dev libxrender-dev libavahi-core-dev libavahi-compat-libdnssd-dev libturbojpeg0-dev libjpeg-dev libssl-dev + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + queries: +security-and-quality + config-file: ./.github/config/codeql.yml + + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{ matrix.language }}" + upload: False + output: sarif-results + + - name: Filter SARIF + uses: advanced-security/filter-sarif@v1 + with: + patterns: | + -**/dependencies/** + -**/moc_*.cpp + -**/libsrc/flatbufserver/hyperion_request_generated.h + -**/libsrc/protoserver/message.pb.cc + -**/libsrc/protoserver/message.pb.h + input: sarif-results/${{ matrix.language }}.sarif + output: sarif-results/${{ matrix.language }}.sarif + + - name: Upload SARIF + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: sarif-results/${{ matrix.language }}.sarif + - name: Upload loc as a Build Artifact + uses: actions/upload-artifact@v2.2.0 + with: + name: sarif-results + path: sarif-results + retention-days: 1 + diff --git a/README.md b/README.md index 5afd7e7e..cf3f7d8b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Latest-Release](https://img.shields.io/github/v/release/hyperion-project/hyperion.ng?include_prereleases&label=Latest%20Release&logo=github&logoColor=white&color=0f83e7)](https://github.com/hyperion-project/hyperion.ng/releases) [![GitHub Actions](https://github.com/hyperion-project/hyperion.ng/workflows/Hyperion%20CI%20Build/badge.svg?branch=master)](https://github.com/hyperion-project/hyperion.ng/actions) -[![LGTM](https://img.shields.io/lgtm/grade/cpp/github/hyperion-project/hyperion.ng?label=Code%20Quality&logo=lgtm&logoColor=white&color=4bc51d)](https://lgtm.com/projects/g/hyperion-project/hyperion.ng/context:cpp) +[![CodeQL Analysis](https://github.com/hyperion-project/hyperion.ng/actions/workflows/codeql.yml/badge.svg)](https://github.com/hyperion-project/hyperion.ng/actions/workflows/codeql.yml) [![Forum](https://img.shields.io/website/https/hyperion-project.org.svg?label=Forum&down_color=red&down_message=offline&up_color=4bc51d&up_message=online&logo=homeadvisor&logoColor=white)](https://www.hyperion-project.org) [![Documentation](https://img.shields.io/website/https/docs.hyperion-project.org.svg?label=Documentation&down_color=red&down_message=offline&up_color=4bc51d&up_message=online&logo=read-the-docs)](https://docs.hyperion-project.org) [![Discord](https://img.shields.io/discord/785578322167463937?label=Discord&logo=discord&logoColor=white&color=4bc51d)](https://discord.gg/khkR8Vx3ff) diff --git a/assets/firmware/arduino/network_bridge/udpraw_serialadalight.py b/assets/firmware/arduino/network_bridge/udpraw_serialadalight.py old mode 100755 new mode 100644 index b46597a9..452f9dd7 --- a/assets/firmware/arduino/network_bridge/udpraw_serialadalight.py +++ b/assets/firmware/arduino/network_bridge/udpraw_serialadalight.py @@ -153,10 +153,9 @@ to this service over the network. srv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - srv.bind(('0.0.0.0', args.localport)) # lgtm [py/bind-socket-all-network-interfaces] + srv.bind(('0.0.0.0', args.localport)) try: - intentional_exit = False while True: try: while True: @@ -180,7 +179,7 @@ to this service over the network. # probably got disconnected break except KeyboardInterrupt: - intentional_exit = True + # intentional_exit raise except socket.error as msg: if args.develop: @@ -190,6 +189,7 @@ to this service over the network. ser_to_net.socket = None sys.stderr.write('Disconnected\n') except KeyboardInterrupt: + # do not handle exceptions pass sys.stderr.write('\n--- exit ---\n') diff --git a/assets/webconfig/js/ui_utils.js b/assets/webconfig/js/ui_utils.js index 74a27061..c20c5fc1 100644 --- a/assets/webconfig/js/ui_utils.js +++ b/assets/webconfig/js/ui_utils.js @@ -1,1340 +1,1340 @@ -var prevTag; - -function removeOverlay() { - $("#loading_overlay").removeClass("overlay"); -} - -function reload() { - location.reload(); -} - -function storageComp() { - if (typeof (Storage) !== "undefined") - return true; - return false; -} - -function getStorage(item) { - if (storageComp()) { - return localStorage.getItem(item); - } - return null; -} - -function setStorage(item, value) { - if (storageComp()) { - localStorage.setItem(item, value); - } -} - -function removeStorage(item) { - if (storageComp()) { - localStorage.removeItem(item); - } -} - -function debugMessage(msg) { - if (window.debugMessagesActive) { - console.log(msg); - } -} - -function validateDuration(d) { - if (typeof d === "undefined" || d < 0) - return ENDLESS; - else - return d *= 1000; -} - -function getHashtag() { - if (getStorage('lasthashtag') != null) - return getStorage('lasthashtag'); - else { - var tag = document.URL; - tag = tag.substr(tag.indexOf("#") + 1); - if (tag == "" || typeof tag === "undefined" || tag.startsWith("http")) - tag = "dashboard" - return tag; - } -} - -function loadContent(event, forceRefresh) { - var tag; - - var lastSelectedInstance = getStorage('lastSelectedInstance'); - - if (lastSelectedInstance && (lastSelectedInstance != window.currentHyperionInstance)) { - if (window.serverInfo.instance[lastSelectedInstance] && window.serverInfo.instance[lastSelectedInstance].running) { - instanceSwitch(lastSelectedInstance); - } else { - removeStorage('lastSelectedInstance'); - } - } - - if (typeof event != "undefined") { - tag = event.currentTarget.hash; - tag = tag.substr(tag.indexOf("#") + 1); - setStorage('lasthashtag', tag); - } - else - tag = getHashtag(); - - if (forceRefresh || prevTag != tag) { - prevTag = tag; - $("#page-content").off(); - $("#page-content").load("/content/" + tag + ".html", function (response, status, xhr) { - if (status == "error") { - tag = 'dashboard'; - console.log("Could not find page:", prevTag, ", Redirecting to:", tag); - setStorage('lasthashtag', tag); - - $("#page-content").load("/content/" + tag + ".html", function (response, status, xhr) { - if (status == "error") { - $("#page-content").html('
' + $.i18n('infoDialog_username_text') + - '
' + $.i18n('infoDialog_password_current_text') + - '
' + $.i18n('infoDialog_password_new_text') + - '
' + $.i18n('infoDialog_username_text') + + '
' + $.i18n('infoDialog_password_current_text') + + '
' + $.i18n('infoDialog_password_new_text') + + '