From 042c8617b9b0c85efdf5a64724d348ea89c19605 Mon Sep 17 00:00:00 2001 From: nthnn Date: Sat, 23 Dec 2023 20:26:32 +0800 Subject: [PATCH] Updated Puppet Build workflow CI. --- .devcontainer.json | 4 - .github/workflows/puppet-build.yml | 7 +- .gitignore | 3 - Ballerina.toml | 8 - Dependencies.toml | 317 ----------------------------- main.bal | 24 --- modules/crypt/decrypt.bal | 16 -- modules/crypt/encrypt.bal | 6 - modules/response/response.bal | 9 - modules/shell/exec.bal | 11 - 10 files changed, 6 insertions(+), 399 deletions(-) delete mode 100644 .devcontainer.json delete mode 100644 .gitignore delete mode 100644 Ballerina.toml delete mode 100644 Dependencies.toml delete mode 100644 main.bal delete mode 100644 modules/crypt/decrypt.bal delete mode 100644 modules/crypt/encrypt.bal delete mode 100644 modules/response/response.bal delete mode 100644 modules/shell/exec.bal diff --git a/.devcontainer.json b/.devcontainer.json deleted file mode 100644 index 000f7b8..0000000 --- a/.devcontainer.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "image": "ballerina/ballerina-devcontainer:2201.8.4", - "extensions": ["WSO2.ballerina"], -} diff --git a/.github/workflows/puppet-build.yml b/.github/workflows/puppet-build.yml index 0746f63..5d350c0 100644 --- a/.github/workflows/puppet-build.yml +++ b/.github/workflows/puppet-build.yml @@ -4,10 +4,15 @@ on: [push] jobs: build: runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./puppet + steps: - name: Checkout uses: actions/checkout@v1 - + - name: Ballerina Build uses: ballerina-platform/ballerina-action@master with: diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 7512ebe..0000000 --- a/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -target -generated -Config.toml diff --git a/Ballerina.toml b/Ballerina.toml deleted file mode 100644 index 4978a1e..0000000 --- a/Ballerina.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -org = "nathannestein" -name = "rheolaeth" -version = "0.1.0" -distribution = "2201.8.4" - -[build-options] -observabilityIncluded = true diff --git a/Dependencies.toml b/Dependencies.toml deleted file mode 100644 index 77a8814..0000000 --- a/Dependencies.toml +++ /dev/null @@ -1,317 +0,0 @@ -# AUTO-GENERATED FILE. DO NOT MODIFY. - -# This file is auto-generated by Ballerina for managing dependency versions. -# It should not be modified by hand. - -[ballerina] -dependencies-toml-version = "2" -distribution-version = "2201.8.4" - -[[package]] -org = "ballerina" -name = "auth" -version = "2.10.0" -dependencies = [ - {org = "ballerina", name = "crypto"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.array"}, - {org = "ballerina", name = "lang.string"}, - {org = "ballerina", name = "log"} -] - -[[package]] -org = "ballerina" -name = "cache" -version = "3.7.0" -dependencies = [ - {org = "ballerina", name = "constraint"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "task"}, - {org = "ballerina", name = "time"} -] - -[[package]] -org = "ballerina" -name = "constraint" -version = "1.5.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "crypto" -version = "2.6.2" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "time"} -] -modules = [ - {org = "ballerina", packageName = "crypto", moduleName = "crypto"} -] - -[[package]] -org = "ballerina" -name = "file" -version = "1.9.0" -dependencies = [ - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "os"}, - {org = "ballerina", name = "time"} -] - -[[package]] -org = "ballerina" -name = "http" -version = "2.10.5" -dependencies = [ - {org = "ballerina", name = "auth"}, - {org = "ballerina", name = "cache"}, - {org = "ballerina", name = "constraint"}, - {org = "ballerina", name = "crypto"}, - {org = "ballerina", name = "file"}, - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "jwt"}, - {org = "ballerina", name = "lang.array"}, - {org = "ballerina", name = "lang.decimal"}, - {org = "ballerina", name = "lang.int"}, - {org = "ballerina", name = "lang.regexp"}, - {org = "ballerina", name = "lang.runtime"}, - {org = "ballerina", name = "lang.string"}, - {org = "ballerina", name = "lang.value"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "mime"}, - {org = "ballerina", name = "oauth2"}, - {org = "ballerina", name = "observe"}, - {org = "ballerina", name = "time"}, - {org = "ballerina", name = "url"} -] -modules = [ - {org = "ballerina", packageName = "http", moduleName = "http"}, - {org = "ballerina", packageName = "http", moduleName = "http.httpscerr"} -] - -[[package]] -org = "ballerina" -name = "io" -version = "1.6.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.value"} -] -modules = [ - {org = "ballerina", packageName = "io", moduleName = "io"} -] - -[[package]] -org = "ballerina" -name = "jballerina.java" -version = "0.0.0" - -[[package]] -org = "ballerina" -name = "jwt" -version = "2.10.0" -dependencies = [ - {org = "ballerina", name = "cache"}, - {org = "ballerina", name = "crypto"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.int"}, - {org = "ballerina", name = "lang.string"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "time"} -] - -[[package]] -org = "ballerina" -name = "lang.__internal" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.object"} -] - -[[package]] -org = "ballerina" -name = "lang.array" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.__internal"} -] - -[[package]] -org = "ballerina" -name = "lang.decimal" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "lang.int" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.__internal"}, - {org = "ballerina", name = "lang.object"} -] - -[[package]] -org = "ballerina" -name = "lang.object" -version = "0.0.0" - -[[package]] -org = "ballerina" -name = "lang.regexp" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] -modules = [ - {org = "ballerina", packageName = "lang.regexp", moduleName = "lang.regexp"} -] - -[[package]] -org = "ballerina" -name = "lang.runtime" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "lang.string" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.regexp"} -] - -[[package]] -org = "ballerina" -name = "lang.value" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "log" -version = "2.9.0" -dependencies = [ - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.value"}, - {org = "ballerina", name = "observe"} -] - -[[package]] -org = "ballerina" -name = "mime" -version = "2.9.0" -dependencies = [ - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.int"} -] -modules = [ - {org = "ballerina", packageName = "mime", moduleName = "mime"} -] - -[[package]] -org = "ballerina" -name = "oauth2" -version = "2.10.0" -dependencies = [ - {org = "ballerina", name = "cache"}, - {org = "ballerina", name = "crypto"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "time"}, - {org = "ballerina", name = "url"} -] - -[[package]] -org = "ballerina" -name = "observe" -version = "1.2.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "os" -version = "1.8.0" -dependencies = [ - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"} -] -modules = [ - {org = "ballerina", packageName = "os", moduleName = "os"} -] - -[[package]] -org = "ballerina" -name = "task" -version = "2.5.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "time"} -] - -[[package]] -org = "ballerina" -name = "time" -version = "2.4.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "url" -version = "2.4.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerinai" -name = "observe" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "observe"} -] -modules = [ - {org = "ballerinai", packageName = "observe", moduleName = "observe"} -] - -[[package]] -org = "nathannestein" -name = "rheolaeth" -version = "0.1.0" -dependencies = [ - {org = "ballerina", name = "crypto"}, - {org = "ballerina", name = "http"}, - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "lang.regexp"}, - {org = "ballerina", name = "mime"}, - {org = "ballerina", name = "os"}, - {org = "ballerinai", name = "observe"} -] -modules = [ - {org = "nathannestein", packageName = "rheolaeth", moduleName = "rheolaeth"}, - {org = "nathannestein", packageName = "rheolaeth", moduleName = "rheolaeth.crypt"}, - {org = "nathannestein", packageName = "rheolaeth", moduleName = "rheolaeth.response"}, - {org = "nathannestein", packageName = "rheolaeth", moduleName = "rheolaeth.shell"} -] - diff --git a/main.bal b/main.bal deleted file mode 100644 index 6f11c23..0000000 --- a/main.bal +++ /dev/null @@ -1,24 +0,0 @@ -import ballerina/http; - -import rheolaeth.crypt; -import rheolaeth.response; -import rheolaeth.shell; - -configurable int port = ?; -configurable string key = ?; - -service / on new http:Listener(port) { - resource function get payload(string command, string? args) returns string { - string|error shellResult = shell:shellExecute(command, [args ?: ""]); - if shellResult is error { - return response:errorResponse(shellResult.message()); - } - - string|error encryptedResult = crypt:aesEcbEncrypt(key, shellResult); - if encryptedResult is error { - return response:errorResponse(encryptedResult.message()); - } - - return response:successResponse(encryptedResult); - } -} diff --git a/modules/crypt/decrypt.bal b/modules/crypt/decrypt.bal deleted file mode 100644 index 5f57c6e..0000000 --- a/modules/crypt/decrypt.bal +++ /dev/null @@ -1,16 +0,0 @@ -import ballerina/crypto; -import ballerina/mime; - -public isolated function aesEcbDecrypt(string key, string encodedMessage) returns string | error { - byte[] fromEncrypted = []; - var result = mime:base64Decode(encodedMessage.toBytes()); - if result is byte[] { - fromEncrypted = result; - } - else { - return error("Cannot decode base64."); - } - - byte[] decryptedBytes = check crypto:decryptAesEcb(fromEncrypted, key.toBytes()); - return string:fromBytes(decryptedBytes); -} \ No newline at end of file diff --git a/modules/crypt/encrypt.bal b/modules/crypt/encrypt.bal deleted file mode 100644 index 9e31123..0000000 --- a/modules/crypt/encrypt.bal +++ /dev/null @@ -1,6 +0,0 @@ -import ballerina/crypto; - -public isolated function aesEcbEncrypt(string key, string message) returns string | error { - byte[] encryptedBytes = check crypto:encryptAesEcb(message.toBytes(), key.toBytes()); - return encryptedBytes.toBase64(); -} diff --git a/modules/response/response.bal b/modules/response/response.bal deleted file mode 100644 index 9d1b3df..0000000 --- a/modules/response/response.bal +++ /dev/null @@ -1,9 +0,0 @@ -import ballerina/lang.regexp; - -public isolated function errorResponse(string message) returns string { - return "{\"status\": \"0\", \"message\": \"" + regexp:replaceAll(re `[\\"]`, message, "\\\"", 0) + "\"}"; -} - -public isolated function successResponse(string content) returns string { - return "{\"status\": \"1\", \"content\": \"" + content + "\"}"; -} \ No newline at end of file diff --git a/modules/shell/exec.bal b/modules/shell/exec.bal deleted file mode 100644 index 4c01d89..0000000 --- a/modules/shell/exec.bal +++ /dev/null @@ -1,11 +0,0 @@ -import ballerina/io; -import ballerina/os; - -public isolated function shellExecute(string command, string[]? arguments) returns string | error { - os:Process proc = check os:exec({ - value: command, - arguments: arguments ?: [] - }, BAL_CONFIG_FILE = "Config.toml"); - - return string:fromBytes(check proc.output(io:stdout)); -} \ No newline at end of file