Skip to content

Commit

Permalink
Add codeql workflow (#190)
Browse files Browse the repository at this point in the history
* Add codeql workflow

* Don't use AutoBuild

* Fix security issue recognised by codeql

* A better fix
  • Loading branch information
adam-fowler committed Apr 29, 2023
1 parent 459af75 commit 8d84d77
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
41 changes: 41 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CODEQL_ENABLE_EXPERIMENTAL_FEATURES_SWIFT: true

jobs:
analyze:
name: Analyze
runs-on: macos-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'swift' ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Build
run: swift build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
3 changes: 2 additions & 1 deletion Sources/HummingbirdFoundation/Files/FileMiddleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@ extension HBFileMiddleware {
}

private func matchRegex(_ string: String, expression: String) -> [Substring] {
let nsRange = NSRange(string.startIndex..<string.endIndex, in: string)
guard let regularExpression = try? NSRegularExpression(pattern: expression, options: []),
let firstMatch = regularExpression.firstMatch(in: string, range: NSMakeRange(0, string.count))
let firstMatch = regularExpression.firstMatch(in: string, range: nsRange)
else {
return []
}
Expand Down

0 comments on commit 8d84d77

Please sign in to comment.