-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
github action for mac and linux for OWASP/wrongsecrets#615
- Loading branch information
Showing
2 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!") |