diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 823791d..52337e9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,11 +8,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '16' - - name: npm install - run: npm ci - - name: npm test - run: npm test \ No newline at end of file + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + - run: npm ci + - run: npm test \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..7cf378e --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "larshp.vscode-abaplint" + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..a55f4e9 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,20 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "All Unit Tests", + "type": "node", + "request": "launch", + "pauseForSourceMap": true, + "trace": false, + "skipFiles": [ + "/**", + "${workspaceFolder}/output/cl_*", + "${workspaceFolder}/output/index.mjs", + "${workspaceFolder}/node_modules/@abaplint/runtime/**" + ], + "preLaunchTask": "npm: build", + "program": "${workspaceFolder}/output/index.mjs", + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index b9e8d59..90fd4b5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,10 @@ # open-abap-ssh + +Run on: Node.js & ECC + +Run on Steampunk if/when it supports TCP/IP + +## Protocol SSH client implemented in ABAP, over TCP/IP with 1 byte frame sizes = slow. https://datatracker.ietf.org/doc/html/rfc4251 - The Secure Shell (SSH) Protocol Architecture diff --git a/abaplint.jsonc b/abaplint.jsonc index 70597ea..97595e8 100644 --- a/abaplint.jsonc +++ b/abaplint.jsonc @@ -13,13 +13,33 @@ "errorNamespace": "." }, "rules": { + "cds_comment_style": true, + "change_if_to_case": true, + "cds_legacy_view": true, + "classic_exceptions_overlap": true, + "local_testclass_consistency": true, + "no_external_form_calls": true, + "no_inline_in_optional_branches": true, + "no_public_attributes": true, + "nrob_consistency": true, + "pragma_style": true, + "slow_parameter_passing": true, + "superfluous_value": true, + "unnecessary_pragma": true, "7bit_ascii": true, "abapdoc": false, "align_parameters": true, "allowed_object_naming": true, "allowed_object_types": false, "ambiguous_statement": true, - "avoid_use": true, + "avoid_use": { + "define": true, + "statics": true, + "defaultKey": true, + "break": false, // todo + "testSeams": true, + "describeLines": true + }, "begin_end_names": true, "begin_single_include": true, "call_transaction_authority_check": true, @@ -29,7 +49,6 @@ "check_comments": false, "check_ddic": true, "check_include": true, - "check_no_handler_pragma": true, "check_subrc": true, "check_syntax": true, "check_text_elements": true, @@ -44,79 +63,21 @@ "mapping": [] }, "constructor_visibility_public": true, - "contains_tab": { - "exclude": [], - "severity": "Error", - "spaces": 1 - }, - "cyclic_oo": { - "exclude": [], - "severity": "Error", - "skip": [] - }, - "cyclomatic_complexity": { - "exclude": [], - "severity": "Error", - "max": 20 - }, - "dangerous_statement": { - "exclude": [], - "severity": "Error", - "execSQL": true, - "kernelCall": true, - "systemCall": true, - "insertReport": true, - "generateDynpro": true, - "generateReport": true, - "generateSubroutine": true, - "deleteReport": true, - "deleteTextpool": true, - "deleteDynpro": true, - "importDynpro": true, - "dynamicSQL": true - }, + "contains_tab": true, + "cyclic_oo": true, + "cyclomatic_complexity": true, + "dangerous_statement": true, "db_operation_in_loop": true, "definitions_top": true, "description_empty": true, - "double_space": { - "exclude": [], - "severity": "Error", - "keywords": true, - "startParen": true, - "endParen": true, - "afterColon": true - }, + "double_space": true, "downport": true, - "empty_line_in_statement": { - "exclude": [], - "severity": "Error", - "allowChained": false - }, + "empty_line_in_statement": true, "empty_statement": true, - "empty_structure": { - "exclude": [], - "severity": "Error", - "loop": true, - "if": true, - "while": true, - "case": true, - "select": true, - "do": true, - "at": true, - "try": true - }, - "exit_or_check": { - "exclude": [], - "severity": "Error", - "allowExit": false, - "allowCheck": false - }, + "empty_structure": true, + "exit_or_check": true, "exporting": true, - "forbidden_identifier": { - "exclude": [], - "severity": "Error", - "check": [] - }, + "forbidden_identifier": true, "forbidden_pseudo_and_pragma": { "exclude": [], "severity": "Error", @@ -145,50 +106,13 @@ "identical_form_names": true, "if_in_if": true, "implement_methods": true, - "in_statement_indentation": { - "exclude": [], - "severity": "Error", - "blockStatements": 2, - "ignoreExceptions": true - }, - "indentation": { - "exclude": [], - "severity": "Error", - "ignoreExceptions": true, - "alignTryCatch": false, - "selectionScreenBlockIndentation": false, - "globalClassSkipFirst": false, - "ignoreGlobalClassDefinition": false, - "ignoreGlobalInterface": false - }, + "in_statement_indentation": true, + "indentation": true, "inline_data_old_versions": true, - "intf_referencing_clas": { - "exclude": [], - "severity": "Error", - "allow": [] - }, - "keep_single_parameter_on_one_line": { - "exclude": [], - "severity": "Error", - "length": 120 - }, - "keyword_case": { - "exclude": [], - "severity": "Error", - "style": "upper", - "ignoreExceptions": true, - "ignoreLowerClassImplmentationStatement": true, - "ignoreGlobalClassDefinition": false, - "ignoreGlobalInterface": false, - "ignoreFunctionModuleName": false, - "ignoreGlobalClassBoundaries": false, - "ignoreKeywords": [] - }, - "line_break_multiple_parameters": { - "exclude": [], - "severity": "Error", - "count": 1 - }, + "intf_referencing_clas": true, + "keep_single_parameter_on_one_line": true, + "keyword_case": true, + "line_break_multiple_parameters": true, "line_break_style": false, "line_length": { "exclude": [], @@ -210,7 +134,6 @@ "exception": "^LCX_.+$", "test": "^LTCL_.+$" }, - "local_testclass_location": true, "local_variable_names": { "exclude": [], "severity": "Error", @@ -245,11 +168,6 @@ "newline_between_methods": true, "no_aliases": true, "no_chained_assignment": true, - "no_public_attributes": { - "exclude": [], - "severity": "Error", - "allowReadOnly": false - }, "no_yoda_conditions": { "exclude": [], "severity": "Error", @@ -287,7 +205,6 @@ "parser_702_chaining": true, "parser_error": true, "parser_missing_space": true, - "pragma_placement": true, "prefer_corresponding": true, "prefer_inline": true, "prefer_is_not": true, diff --git a/package-lock.json b/package-lock.json index 8a998db..87c8c0a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,51 +9,97 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@abaplint/cli": "^2.89.0", - "@abaplint/runtime": "^2.0.9", - "@abaplint/transpiler-cli": "^2.0.9" + "@abaplint/cli": "^2.113.108", + "@abaplint/runtime": "^2.10.42", + "@abaplint/transpiler-cli": "^2.10.42" } }, "node_modules/@abaplint/cli": { - "version": "2.89.0", - "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.89.0.tgz", - "integrity": "sha512-N+qpOa1BkHDglX4ibITrxpJvRN3JIesRumuePMDPkee2bqNfDfgq6xZedLoWI2kUsAj5DpiWdKbNY4nBme0WIg==", + "version": "2.113.108", + "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.113.108.tgz", + "integrity": "sha512-Qigo5UBwb0a2yskWJwYGgRfj7hx9rZ45sUb6kxQuMG/ZUT4xAIKIXxYf/hWQMqM+xSP4p85uIjDAs64rNzDQ9A==", + "license": "MIT", "bin": { "abaplint": "abaplint" }, "engines": { "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/larshp" } }, "node_modules/@abaplint/runtime": { - "version": "2.0.9", - "resolved": "https://registry.npmjs.org/@abaplint/runtime/-/runtime-2.0.9.tgz", - "integrity": "sha512-z6jIDF/98+DAVDdM5LYeBNLIJrh4Mg/EIa3C+ESCokLevGMCTynuGomg3E8mv9/Cu+YxWA0SPMzcGof0i7jg7Q==" + "version": "2.10.42", + "resolved": "https://registry.npmjs.org/@abaplint/runtime/-/runtime-2.10.42.tgz", + "integrity": "sha512-dXjCY4DSfd5NKPe3mt7wXJsi/MTHUsRppDfX4f/dypRueQTkxdX8J2GbUl+hKwF+xE841g1LzxZQmkzNRt/odw==", + "license": "MIT", + "dependencies": { + "temporal-polyfill": "^0.2.5" + }, + "funding": { + "url": "https://github.com/sponsors/larshp" + } }, "node_modules/@abaplint/transpiler-cli": { - "version": "2.0.9", - "resolved": "https://registry.npmjs.org/@abaplint/transpiler-cli/-/transpiler-cli-2.0.9.tgz", - "integrity": "sha512-1prLaF03TqQ5OAndGt1BhmUQXjw9Ip0HKVWftyjc7KvFq2P/QscLqB5EuLiOnzIOKnBFt6bb6CLJgFTNRJTdWw==", + "version": "2.10.42", + "resolved": "https://registry.npmjs.org/@abaplint/transpiler-cli/-/transpiler-cli-2.10.42.tgz", + "integrity": "sha512-gdgzYfN4uCX6XUX0XfR6p67TQilqghLJ/sU6JBzzn3EIx2cbi2orC3/xsV4xtoFnV9F0jDx+RCCzYcYGHzwSyg==", + "license": "MIT", "bin": { "abap_transpile": "abap_transpile" + }, + "funding": { + "url": "https://github.com/sponsors/larshp" } + }, + "node_modules/temporal-polyfill": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/temporal-polyfill/-/temporal-polyfill-0.2.5.tgz", + "integrity": "sha512-ye47xp8Cb0nDguAhrrDS1JT1SzwEV9e26sSsrWzVu+yPZ7LzceEcH0i2gci9jWfOfSCCgM3Qv5nOYShVUUFUXA==", + "license": "MIT", + "dependencies": { + "temporal-spec": "^0.2.4" + } + }, + "node_modules/temporal-spec": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/temporal-spec/-/temporal-spec-0.2.4.tgz", + "integrity": "sha512-lDMFv4nKQrSjlkHKAlHVqKrBG4DyFfa9F74cmBZ3Iy3ed8yvWnlWSIdi4IKfSqwmazAohBNwiN64qGx4y5Q3IQ==", + "license": "ISC" } }, "dependencies": { "@abaplint/cli": { - "version": "2.89.0", - "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.89.0.tgz", - "integrity": "sha512-N+qpOa1BkHDglX4ibITrxpJvRN3JIesRumuePMDPkee2bqNfDfgq6xZedLoWI2kUsAj5DpiWdKbNY4nBme0WIg==" + "version": "2.113.108", + "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.113.108.tgz", + "integrity": "sha512-Qigo5UBwb0a2yskWJwYGgRfj7hx9rZ45sUb6kxQuMG/ZUT4xAIKIXxYf/hWQMqM+xSP4p85uIjDAs64rNzDQ9A==" }, "@abaplint/runtime": { - "version": "2.0.9", - "resolved": "https://registry.npmjs.org/@abaplint/runtime/-/runtime-2.0.9.tgz", - "integrity": "sha512-z6jIDF/98+DAVDdM5LYeBNLIJrh4Mg/EIa3C+ESCokLevGMCTynuGomg3E8mv9/Cu+YxWA0SPMzcGof0i7jg7Q==" + "version": "2.10.42", + "resolved": "https://registry.npmjs.org/@abaplint/runtime/-/runtime-2.10.42.tgz", + "integrity": "sha512-dXjCY4DSfd5NKPe3mt7wXJsi/MTHUsRppDfX4f/dypRueQTkxdX8J2GbUl+hKwF+xE841g1LzxZQmkzNRt/odw==", + "requires": { + "temporal-polyfill": "^0.2.5" + } }, "@abaplint/transpiler-cli": { - "version": "2.0.9", - "resolved": "https://registry.npmjs.org/@abaplint/transpiler-cli/-/transpiler-cli-2.0.9.tgz", - "integrity": "sha512-1prLaF03TqQ5OAndGt1BhmUQXjw9Ip0HKVWftyjc7KvFq2P/QscLqB5EuLiOnzIOKnBFt6bb6CLJgFTNRJTdWw==" + "version": "2.10.42", + "resolved": "https://registry.npmjs.org/@abaplint/transpiler-cli/-/transpiler-cli-2.10.42.tgz", + "integrity": "sha512-gdgzYfN4uCX6XUX0XfR6p67TQilqghLJ/sU6JBzzn3EIx2cbi2orC3/xsV4xtoFnV9F0jDx+RCCzYcYGHzwSyg==" + }, + "temporal-polyfill": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/temporal-polyfill/-/temporal-polyfill-0.2.5.tgz", + "integrity": "sha512-ye47xp8Cb0nDguAhrrDS1JT1SzwEV9e26sSsrWzVu+yPZ7LzceEcH0i2gci9jWfOfSCCgM3Qv5nOYShVUUFUXA==", + "requires": { + "temporal-spec": "^0.2.4" + } + }, + "temporal-spec": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/temporal-spec/-/temporal-spec-0.2.4.tgz", + "integrity": "sha512-lDMFv4nKQrSjlkHKAlHVqKrBG4DyFfa9F74cmBZ3Iy3ed8yvWnlWSIdi4IKfSqwmazAohBNwiN64qGx4y5Q3IQ==" } } } diff --git a/package.json b/package.json index 14f787a..2b8b02f 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "description": "open-abap-ssh", "scripts": { "test": "npx abaplint && npm run unit", - "unit": "rm -rf output && abap_transpile test/abap_transpile.json && echo RUNNING && node output/index.mjs" + "build": "rm -rf output && abap_transpile test/abap_transpile.json", + "unit": "npm run build && echo RUNNING && node output/index.mjs" }, "repository": { "type": "git", @@ -18,8 +19,8 @@ }, "homepage": "https://github.com/open-abap/open-abap-ssh#readme", "dependencies": { - "@abaplint/cli": "^2.89.0", - "@abaplint/runtime": "^2.0.9", - "@abaplint/transpiler-cli": "^2.0.9" + "@abaplint/cli": "^2.113.108", + "@abaplint/runtime": "^2.10.42", + "@abaplint/transpiler-cli": "^2.10.42" } } diff --git a/src/zcl_oassh.clas.abap b/src/zcl_oassh.clas.abap index b527908..826fc22 100644 --- a/src/zcl_oassh.clas.abap +++ b/src/zcl_oassh.clas.abap @@ -112,12 +112,13 @@ CLASS ZCL_OASSH IMPLEMENTATION. METHOD if_apc_wsp_event_handler~on_message. DATA lv_message TYPE xstring. + DATA lx_error TYPE REF TO cx_root. TRY. lv_message = i_message->get_binary( ). mo_stream->append( lv_message ). handle( ). - CATCH cx_root INTO DATA(lx_error). + CATCH cx_root INTO lx_error. BREAK-POINT. ENDTRY. ENDMETHOD. diff --git a/src/zcl_oassh_message_ecdh_30.clas.abap b/src/zcl_oassh_message_ecdh_30.clas.abap index 6e633e7..efcf9ed 100644 --- a/src/zcl_oassh_message_ecdh_30.clas.abap +++ b/src/zcl_oassh_message_ecdh_30.clas.abap @@ -35,11 +35,21 @@ CLASS ZCL_OASSH_MESSAGE_ECDH_30 IMPLEMENTATION. METHOD parse. - BREAK-POINT. +* https://datatracker.ietf.org/doc/html/rfc5656#section-7.1 +* https://datatracker.ietf.org/doc/html/rfc5656#section-4 + + rs_data-message_id = io_stream->take( 1 ). + ASSERT rs_data-message_id = gc_message_id. + rs_data-q_c = io_stream->string_decode( ). + ENDMETHOD. METHOD serialize. - BREAK-POINT. + + CREATE OBJECT ro_stream. + ro_stream->append( gc_message_id ). + ro_stream->string_encode( is_data-q_c ). + ENDMETHOD. ENDCLASS. diff --git a/src/zcl_oassh_message_ecdh_31.clas.abap b/src/zcl_oassh_message_ecdh_31.clas.abap index c068aac..d6f0d5f 100644 --- a/src/zcl_oassh_message_ecdh_31.clas.abap +++ b/src/zcl_oassh_message_ecdh_31.clas.abap @@ -37,11 +37,25 @@ CLASS ZCL_OASSH_MESSAGE_ECDH_31 IMPLEMENTATION. METHOD parse. - BREAK-POINT. +* https://datatracker.ietf.org/doc/html/rfc5656#section-7.1 +* https://datatracker.ietf.org/doc/html/rfc5656#section-4 + + rs_data-message_id = io_stream->take( 1 ). + ASSERT rs_data-message_id = gc_message_id. + rs_data-k_s = io_stream->string_decode( ). + rs_data-q_s = io_stream->string_decode( ). + rs_data-signature = io_stream->string_decode( ). + ENDMETHOD. METHOD serialize. - BREAK-POINT. + + CREATE OBJECT ro_stream. + ro_stream->append( gc_message_id ). + ro_stream->string_encode( is_data-k_s ). + ro_stream->string_encode( is_data-q_s ). + ro_stream->string_encode( is_data-signature ). + ENDMETHOD. ENDCLASS.