YubiHSM2: Working command sequence in yubihsm-shell won't work non-interactively on command line - yubico

I got a working sequence of commands within yubihsm-shell, but cannot get the same result when calling the shell non-interactively from the command line.
In the shell I got:
yubihsm> connect
yubihsm> session open 2 MyPassword
yubihsm> set informat base64
yubihsm> set outformat hex
yubihsm> decrypt oaep 0 0x1ddd rsa-oaep-sha1 wrapped_ephemeral.txt
On the command line I have currently this (I unfortunately need to be on Windows for that, so this cmd syntax)
set YUBISHELL="c:\Program Files\Yubico\YubiHSM Shell\bin\yubihsm-shell.exe"
type wrapped_ephemeral.txt | %YUBISHELL% ^
--authkey=2 ^
--password=MyPassword ^
--algorithm=rsa-oaep-sha1 ^
--informat=base64 ^
--outformat=hex ^
--object-id=7645 ^
--action=decrypt-oaep
All I'll get is
Session keepalive set up to run every 15 seconds
Created session 0
Command not implemented: Generic error
However, connecting and authenticating works ...
%YUBISHELL% ^
--authkey=2 ^
--password=MyPassword ^
--action=get-device-info
... as I get this
Using default connector URL: http://127.0.0.1:12345
Session keepalive set up to run every 15 seconds
Version number: 2.2.0
Serial number: ........
Log used: 62/62
Supported algorithms: rsa-pkcs1-sha1, rsa-pkcs1-sha256, rsa-pkcs1-sha384,
rsa-pkcs1-sha512, rsa-pss-sha1, rsa-pss-sha256,
rsa-pss-sha384, rsa-pss-sha512, rsa2048,
rsa3072, rsa4096, ecp256,
ecp384, ecp521, eck256,
ecbp256, ecbp384, ecbp512,
hmac-sha1, hmac-sha256, hmac-sha384,
hmac-sha512, ecdsa-sha1, ecdh,
rsa-oaep-sha1, rsa-oaep-sha256, rsa-oaep-sha384,
rsa-oaep-sha512, aes128-ccm-wrap, opaque-data,
opaque-x509-certificate, mgf1-sha1, mgf1-sha256,
mgf1-sha384, mgf1-sha512, template-ssh,
aes128-yubico-otp, aes128-yubico-authentication, aes192-yubico-otp,
aes256-yubico-otp, aes192-ccm-wrap, aes256-ccm-wrap,
ecdsa-sha256, ecdsa-sha384, ecdsa-sha512,
ed25519, ecp224, rsa-pkcs1-decrypt,

The error message "Command not implemented: Generic error" is meant seriously and is not due an mistake by me.
Incomprehensibly, some commands are only available in the interactive mode of the shell.
Known Issues and Limitations
Unimplemented Commands When Invoked in Command-Line Mode
...
decrypt-oaep
...
(https://developers.yubico.com/YubiHSM2/Releases/Known_issues.html)

Related

Escaping a space in a properties file for WildFly with Oracle DB

I am having a hard time using an environment variable with a space in a properties file read by WildFly (24) in Linux using Oracle 19 in RDS. One like:
SELECT 1 FROM DUAL
The issue is that wildfly won't even parse the file if the spaces are in there with the normal quoting methods.
I have it setup so that variable is in a file called datasource.properties that gets read from standalone.conf where this variable sits:
JAVA_OPTS="$JAVA_OPTS -DDATABASE_CONNECTION_CHECK=${DATABASE_CONNECTION_CHECK}"
It's read in with the following in standalone.conf:
set -a
. /opt/wildfly_config/datasource.properties
set +a
That in turn gets populated in standalone.xml with:
<connection-url>${env.DATABASE_JDBC_URL}</connection-url>
I try putting it in quotes and oddly enough it doesn’t start at all. Standalone.sh is no longer able to parse it:
Error: Could not find or load main class 1 Caused by: java.lang.ClassNotFoundException: 1
I have tried many things such as:
DATABASE_CONNECTION_CHECK="SELECT{ }1{ }FROM{ }DUAL"
DATABASE_CONNECTION_CHECK="'SELECT 1 FROM DUAL'"
DATABASE_CONNECTION_CHECK='SELECT 1 FROM DUAL'
DATABASE_CONNECTION_CHECK="SELECT+1+FROM+DUAL"
DATABASE_CONNECTION_CHECK="SELECT\ 1\ FROM\ DUAL"
DATABASE_CONNECTION_CHECK="\"SELECT 1 FROM DUAL\""
DATABASE_CONNECTION_CHECK="\"'SELECT 1 FROM DUAL'\""
DATABASE_CONNECTION_CHECK="SELECT%201%20FROM%20DUAL"
DATABASE_CONNECTION_CHECK="SELECT\{ }1\{ }FROM\{ }DUAL"
DATABASE_CONNECTION_CHECK='SELECT{ }1{ }FROM{ }DUAL'
DATABASE_CONNECTION_CHECK="'SELECT{ }1{ }FROM{ }DUAL'"
DATABASE_CONNECTION_CHECK="''SELECT{ }1{ }FROM{ }DUAL''"
DATABASE_CONNECTION_CHECK="SELECT%1%FROM%DUAL"
(I realize some of these don't make sense but I was looking for anything different.)
Startup looks good in the log output this with some of these, but then java doesn’t like it, for some reason it sees the escape usage:
Caused by: Error : 936, Position : 9, Sql = SELECT+1+FROM+DUAL, OriginalSql = SELECT+1+FROM+DUAL, Error Msg = ORA-00936: missing expression
or
Caused by: Error : 911, Position : 6, Sql = SELECT%1%FROM%DUAL, OriginalSql = SELECT%1%FROM%DUAL, Error Msg = ORA-00911: invalid character
or
WARN [org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory] (ServerService Thread Pool -- 46) IJ030027: Destroying connection that is not valid, due to the following exception: oracle.jdbc.driver.T4CConnection#2c1456f8: java.sql.SQLException: Non supported SQL92 token at position: 7
This last one is the only one that really netted anything different. I got that with:
DATABASE_CONNECTION_CHECK="SELECT{}1{}FROM{}DUAL"
I can use sed to change the value in the standalone.xml, but all of the other properties I am doing work fine with the exception of this one. I had a hard time with a semicolon in the jdbc string with MSSQL and putting the semicolon in braces like "{;}" fixed that. This DB apparently does not follow the same syntax.
Is there an encoding type that will help this with Oracle and keeps wildfly happy?
EDIT: More tests:
DATABASE_CONNECTION_CHECK=\"SELECT' '1' 'FROM' 'DUAL\"
gets
Caused by: Error : 900, Position : 0, Sql = "SELECT 1 FROM DUAL", OriginalSql = "SELECT 1 FROM DUAL", Error Msg = ORA-00900: invalid SQL statement'
(doesn't seem to like the quotes)
But without the escaping of the quotes I get:
Caused by: Error : 923, Position : 9, Sql = SELECT' '1' 'FROM' 'DUAL, OriginalSql = SELECT' '1' 'FROM' 'DUAL, Error Msg = ORA-00923: FROM keyword not found where expected
A better solution was to change the sourcing of the file from:
set +a
. /opt/PrimeKey/wildfly_config/datasource.properties
set -a
to
. /opt/PrimeKey/wildfly_config/datasource.properties
and make it so all the variables brought in were variables and not properties:
export DATABASE_CONNECTION_CHECK="SELECT 1 FROM DUAL"

facing ERROR: ArgumentError: wrong number of arguments (given 3, expected 2) ruby 3 aruba

after upgrading ruby from 2.7 to 3.0 to 3.1 I am facing fowling issue while running the cucumber test
Given a local mode chef repo with nodes 'one,two,three' # features/step_definitions/chef-repo.rb:2
Expected `knife client create admin -c config.rb -f admin.pem` to succeed but got non-zero exit status and the following output:
ERROR: ArgumentError: wrong number of arguments (given 3, expected 2)
(RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/chef-repo.rb:66:in `create_client'
./features/step_definitions/chef-repo.rb:58:in `create_admin'
./features/step_definitions/chef-repo.rb:20:in `block (2 levels) in <top (required)>'
./features/step_definitions/chef-repo.rb:19:in `each'
./features/step_definitions/chef-repo.rb:19:in `/^a local mode chef repo with nodes '(.+?)'(?: with admins '(.+?)')?$/'
features/clean.feature:11:in `a local mode chef repo with nodes 'one,two,three''
And I create a vault item 'test/item' containing the JSON '{"foo": "bar"}' encrypted for 'one,two' # features/step_definitions/chef-vault.rb:4
Then the vault item 'test/item' should be encrypted for 'one,two' # features/step_definitions/chef-vault.rb:48
And I update the vault item 'test/item' to be encrypted for 'two,three' # features/step_definitions/chef-vault.rb:14
Then the vault item 'test/item' should be encrypted for 'one,two,three'
It's failing under Auba SpawnProcess start command. Tried upgrading and downgrading arbua version 'aruba', '~> 2.0' & gem 'aruba', '0.5.4' nothing working can someone please help me with this?
in chef-repo.rb its failing on run_command_and_stop
def create_client(name, args = nil)
command = "knife client create #{name} -c config.rb -f #{name}.pem"
run_command_and_stop(command, fail_on_error: true)
write_file("#{name}.pem", last_command_started.stdout)
end
here if we step in run_command_and_stop its fails on command.start following code in aruba
def start_command(command)
259: aruba.config.run_before_hook(:command, self, command)
260:
261: in_current_directory do
262: command.start
263: end
264:
=> 265: stop_signal = command.stop_signal
266: aruba.announcer.announce(:stop_signal, command.pid, stop_signal) if stop_signal
267:
268: aruba.config.run_after_hook(:command, self, command)
269: end

Minting token in cardano mainnet --tx-out error

I am trying to mint a token in cardano mainnet. I have built a block and staking pool. I am working to mint a token and i am running into an error "unexpected '2', expecting space, "+" or end of input.
Here is the linux code I'm running:
cardano-cli transaction build-raw --shelley-era --fee $fee --tx-in $txhash#$txix --tx-out $address+$output+"$tokenamount $policyid.$tokenname1" --mint="$tokenamount $policyid.$tokenname1" --minting-script-file policy/policy.script --out-file matx.raw
Here is the error:
option --tx-out:
unexpected '2'
expecting space, "+" or end of input
Inputs:
I have tried different outputs of 10000000, 5000000, and 0.
$tokenamount="10000000"
$address=$(cat payment.addr)
$tokenname1="CpoolTest"
https://developers.cardano.org/docs/native-tokens/minting/
Please help
I guess i found the error.
Check $policyid whats inside. It should contain only 1x adress.
Try echo $policyid. It should only display 1 address
If its not the case, yo can try:
to delete your policyID:
rm -rf policy/policyID
After deleting create a brand new one:
cardano-cli transaction policyid --scriptfile ./policy/policy.script >> policy/policyID
Now set the variable:
policyid=$(cat policy/policyID)
Echo it
echo $policyid
There should be exactly 1 address displayed. Your code should work now

Pyomo: sending options="threads" to cbc solver causes an error

It is possible to activate multithreading in a command line:
$cbc -threads=6
Welcome to the CBC MILP Solver
Version: 2.9.9
Build Date: Aug 21 2017
$command line - cbc -threads=6 (default strategy 1)
threads was changed from 0 to 6
But when I try to activate this option in pyomo code
opt = SolverFactory('cbc')
result = opt.solve(instance, options="threads=4")
I get an error:
File "/usr/local/lib/python3.9/dist-packages/pyomo/opt/base/solvers.py", line 561, in solve
self.options.update(kwds.pop('options', {}))
File "/usr/local/lib/python3.9/dist-packages/pyutilib/misc/misc.py", line 360, in update
if type(d[k]) is dict:
TypeError: string indices must be integers
Any ideas?
The options keyword argument expects a dictionary. If you want to use the same syntax as the command line, you're after options_string
opt.solve(instance, options_string="threads=4")
opt.solve(instance, options={"threads": 4})

intero error: wrong-type-argument stringp nil

I'm trying to get intero running. After install, opening a Haskell file from an existing stack project results in:
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
signal(wrong-type-argument (stringp nil))
flycheck-buffer()
flycheck-buffer-automatically()
flycheck-perform-deferred-syntax-check()
set-window-buffer(#<window 1 on Lib.hs> #<buffer Lib.hs>)
window--display-buffer(#<buffer Lib.hs> #<window 1 on Lib.hs> reuse ((inhibit-same-window)))
display-buffer-same-window(#<buffer Lib.hs> ((inhibit-same-window)))
display-buffer(#<buffer Lib.hs> (display-buffer-same-window (inhibit-same-window)))
pop-to-buffer(#<buffer Lib.hs> (display-buffer-same-window (inhibit-same-window)) nil)
pop-to-buffer-same-window(#<buffer Lib.hs>)
find-file("~/test/src/Lib.hs" t)
funcall-interactively(find-file "~/test/src/Lib.hs" t)
call-interactively(find-file nil nil)
command-execute(find-file)
When I run flycheck-buffer in the same buffer, nothing happens, even when there are errors in the source code.
Here are the contents of my .emacs file:
(setq debug-on-error t)
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
(package-refresh-contents)
(package-install 'intero)
(add-hook 'haskell-mode-hook 'intero-mode)
Since I'm on Mac Os I also tried adding (as suggested on the flycheck page):
(package-install 'exec-path-from-shell)
(exec-path-from-shell-initialize)
But it makes no difference.
Here are the installed package versions:
$ ls ~/.emacs.d/elpa/
archives/
company-20191114.1356/
dash-20191109.1327/
epl-20180205.2049/
flycheck-20191126.1329/
haskell-mode-20191120.1923/
intero-20191103.1239/
pkg-info-20150517.1143/
This is using GNU Emacs 26.3.
TL;DR
I found two issues and a (at least temporary) fix for each of them.
I am submitting pull requests for both of them, but in the mean time you can fix the issue for yourself either by editing the intero.el file directly, or (recommended way) by using the great el-patch package.
1) intero-ghc-version not set
This is due to the fact of using the intero-ghc-version local variable instead of calling the function (intero-ghc-version) in the intero-ghci-output-flags function (L.2668) intero.el
Fix: patch the function intero-ghci-output-flags :
replace
(split-string intero-ghc-version "\\."))))
by
(split-string (intero-ghc-version) "\\."))))
(notice the added parentheses)
2) misuse of append for string concatenation in intero-start-process-in-buffer
append is for lists, concat is for strings, an easy mistake, especially when in Haskell String is equivalent to [Char] (so technically... a list!)
fix: patch the function intero-start-process-in-buffer, L.2335 of the intero.el:
replace
(process-send-string process (append ":set " flag "\n")))
by
(process-send-string process (concat ":set " flag "\n")))
line 2335 of the current version of the source code, using el-patch)
Once these modifications are made, you should be up and running!
Initial answer
Same issue here.
Not a definitive answer, but I have the same issue and might have pinned down the issue to the function intero-ghci-output-flags being run as the intero-ghc-version variable is not set properly.
Feel free to correct me as I might have missed some things.
By following the error messages, I confirm it happens in (flycheck-start-current-syntax-check checker) in the flycheck-buffer function.
Running this directly from the haskell buffer shows that the error happens when calling (split-string intero-ghc-version "\\.") from the intero-ghci-output-flags function in the intero.el file (Line 2671).
This tries to split the intero version (as set by the intero-ghc-version function above in the file).
It seems the variable's value is nil, as confirmed by running M-x describe-variable -> intero-ghc-version.
During my tests I got seemingly imprevisible results from (intero-ghc-version).
Sometimes (at least on the first run?) it returns "8.4.4",
sometimes it fails with "Wrong type argument: stringp, (58 115 101 116 32 45 102 111 98 106 ...)
I am able to manually run the function intero-ghci-output-flags and get the proper output without error, once, and it fails if I run it a second time.
the function (intero-ghc-version-raw) consistently returns "8.4.4" however.
After experimenting the error message that spontaneously appears is transformed to:
Debugger entered--Lisp error: (wrong-type-argument stringp (58 115 101 116 32 45 102 111 98 106 101 99 116 45 99 111 100 101 . "\n"))
process-send-string(#<process stack> (58 115 101 116 32 45 102 111 98 106 101 99 116 45 99 111 100 101 . "\n"))
#f(compiled-function (flag) #<bytecode 0x1785fe9>)("-fobject-code")
mapc(#f(compiled-function (flag) #<bytecode 0x1785fe9>) ("-fobject-code"))
intero-start-process-in-buffer(#<buffer intero:backend:pubiber /home/mika/programmation/haskell/pubiber> nil #<buffer Lib.hs> nil)
intero-get-worker-create(backend nil #<buffer Lib.hs> nil)
intero-buffer(backend)
intero-eldoc()
The ASCII char sequence in the error message is ":set -fobject-code".
The "-fobject-code" in the message is the result of the intero-ghci-output-flags function, so it seems it finally worked properly but the rest of the code failed.
Note:
The fact that the file gets re-evaluated whenever intero tries to start a session might to explain why I get inconsistent results when running the functions several times.
PS running arch linux, system updated a few minutes ago, all emacs package updated.
---- EDIT ----
So after looking a bit more, in the function intero-start-process-in-buffer, that uses the flags to start the intero process in the lines 2334-2337:
(set-process-query-on-exit-flag process nil)
(mapc
(lambda (flag)
(process-send-string process (append ":set " flag "\n")))
(intero-ghci-output-flags))
(process-send-string process ":set -fdefer-type-errors\n")
they use append instead of concat to create the command.
replacing append by concat fixes this second error, and intero boots normally and seems to work properly (after setting intero-ghc-version).
---- EDIT 2 ----
Just figured out the original issue:
The function uses the variable intero-ghc-version instead of calling the function with the same name. The function is supposed to act as a lazy loader of the value, calling intero-ghc-version-raw the first time, and returning the cached value the subsequent times.
Calling the variable directly didn't allow the value to be set initially.
See the TL;DR for the temporary fix.

Resources