Skip to content

Commit

Permalink
github action for mac and linux for OWASP/wrongsecrets#615
Browse files Browse the repository at this point in the history
  • Loading branch information
commjoen committed Feb 24, 2024
1 parent b3c45f7 commit 8d9b344
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .github/workflows/compile_swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Compile Swift"

on:
workflow_dispatch:
push:
paths:
- "c/**"
- ".github/**"
pull_request:

permissions:
contents: read

jobs:
build-darwin:
name: MacOS(Intel&ARM)
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Compile Swift for MacOS
run: |
echo "compiling for MacOSP"
(cd swift && swift run -c release --arch arm64 --arch x86_64)
- name: Uploading Swift executables
uses: actions/upload-artifact@v4
with:
name: executable-swift-MacOS
path: swift/.build/apple/Products/Release/wrongsecrets-swift
build-glibclinux:
name: MacOS(Intel&ARM)
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Compile Swift for glibc linux
run: |
echo "compiling for Linux"
mkdir target
(cd swift && docker run -v "$PWD:/sources" -w /sources --platform linux/arm64 swift:latest swift run -c release)
(cd swift && cp .build/aarch64-unknown-linux-gnu/release/wrongsecrets-swift ../target/wrongsecrets-swift-linux-arm)
(cd swift && docker run -v "$PWD:/sources" -w /sources --platform linux/amd64 swift:latest swift run -c release)
(cd swift && cp .build/x86_64-unknown-linux-gnu/release/wrongsecrets-swift ../target/wrongsecrets-swift-linux)
- name: Uploading Swift executables
uses: actions/upload-artifact@v4
with:
name: executable-swift-Linux
path: target/*
23 changes: 22 additions & 1 deletion swift/Sources/main.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
// The Swift Programming Language
// https://docs.swift.org/swift-book
func getSecret() -> String {
let CharArr: [Character] = ["T", "h", "i", "s", " ", "a", " ", "s", "e", "c", "r", "e", "t"]

let newStr = String(CharArr)
return newStr
}
if(CommandLine.arguments.count == 2){
if (CommandLine.arguments[1] == "spoil"){
print(getSecret())
} else {
if (CommandLine.arguments[1] == getSecret()){
print("This is correct! Congrats!");
}else{
print("This is incorrect. Try again");
}
}
} else if (CommandLine.arguments.count==1) {
print("Welcome to the wrongsecrets Swift binary which hides a secret.");
print("Use args spoil or a string to guess the password.");
} else {
print("Too many arguments supplied.");
}

print("Hello, world!")

0 comments on commit 8d9b344

Please sign in to comment.