Is there a tool to inspect / debug contents of Oracle Coherence caches? - oracle-coherence

I'm new to Oracle Coherence, and I'm trying to find a development / debug tool to help me validate my application.
It feels like there should be a straight-forward way of viewing the keys and/or values of a cache (and possibly even run ad-hoc queries and functions?). However I can't find anything except (Oracle Coherence Cache Viewer)[http://www.sl.com/products/coherenceviewer.shtml].
Otherwise I can write something to interrogate the Coherence JMX MBean, use the Coherence command-line interface, or write code myself to query my cache, but this feels like a problem which has been encountered before - hopefully I can recycle something rather than write from scratch?

The best tool I can find is the QueryPlus command-line tool shipped with a full Coherence install %COHERENCE_HOME%\bin\query.cmd or $COHERENCE_HOME/bin/query.sh.
You need to point it to your Coherence config files by setting properties on the JVM:
java -Dtangosol.coherence.cacheconfig=META-INF/wlevs/coherence/coherence-cache-config.xml -Dtangosol.pof.config=my-pof-config.xml ...
You also need to add all jars required to load your user types to the classpath, and get a tangosol-coherence-override.xml in the classpath to define the cluster to join to.

GUI for QueryPlus:
http://code.google.com/p/zh-coherence-viewer/
It can execute CohQL script and show it in table or text pane.

I've been working on a command line tool based on the Coherence C++ client library here:
https://github.com/actsasflinn/coherence-tool
No CohQL yet but supports the following usage which covers most everything I'd want:
./run.sh <cache-name> get <key1> [key2] ...
./run.sh <cache-name> mget
./run.sh <cache-name> put <key> <value>
./run.sh <cache-name> mput <key1> <value1> [<key2> <value2>] ...
./run.sh <cache-name> delete <key> [key2] ...
./run.sh <cache-name> size
./run.sh <cache-name> keys
./run.sh <cache-name> values
./run.sh <cache-name> key_exists <key>
./run.sh <cache-name> value_exists <value>
./run.sh <cache-name> clear

See also "Using Coherence Query Language": http://docs.oracle.com/cd/E15357_01/coh.360/e15723/api_cq.htm

Related

Is it possible to run sqlite dot commands from within Java (Android)?

Is it possible to run sqlite dot commands, e.g. .backup / .restore from Java (Android) with for example SqliteOpenHelper or something else?
Currently I have to run the .backup command using shell using sqlite3 binary and I don't want to do that for efficiency reasons. Also it is cumbersome.
Otherwise, any other way to backup and restore from inside Java / Android?

Is it possible to create a Dynamo DB table with at rest encryption enabled via the Java SDK

As I understand it, it's not possible to enable at rest encryption after a table has been created. I currently use the Java SDK to create tables but can't see any way to request the table to be created with encryption turned on.
I've used the latest SDK:
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-dynamodb</artifactId>
<version>1.11.391</version>
And classes com.amazonaws.services.dynamodbv2.model.CreateTableRequest and com.amazonaws.services.dynamodbv2.util.TableUtils#createTableIfNotExists.
I know another option to create tables would be to use something like the CLI or terraform. However, what I liked about the Java SDK API was that it colocates the "schema" right there in the code along with the Java POJO mappings that use it, making it easy to run in tests against the local dynamo db. If I need to write terraform files or scripts to call the CLI these kind of fall "out of band" with the actual code that uses it which feels less ideal.
Is there any way to do this with the Java SDK?

Creating OpenVAS scan config through CLI (OMP)

Is there any way around to create a scan configuration(scan config) for OpenVAS running in CentOS 7 by specifying the NVT-Families by means of the OMP command create_config ?
If so, please provide a detailed example.
I don't know about creating a scan config by specifiying only the NVT families but you can for ex download a config from the greenbone gui and then add
<create_config>YOUR CONFIG RESPONSE GOES HERE</create_config>
Then easily you can with omp
cat scan-config.xml | $CS_OMP -u $USER_NAME -w $USER_PASSWORD -i -X -
Ref: http://docs.greenbone.net/API/OMP/omp-7.0.html#command_create_config
This is the only major drawback to automation via OpenVas. You can create a scan config solely using OMP, but how you specify the NVT's to use in config is backwards. You can't specify simply the NVT's you would not like to use. You have to specify the NVT's you'd like to use minus the ones you don't.
i.e. You grab a list of all families, and within each family, you specify every NVT you want by grabbing a list of all nvts within that family. You then modify a cloned default config using repeated calls to modify_config for each family, including all the NVT's you wanted to use in that family.
It is super painful. Nearly every article on the web details either basic scanning, or gui usage which is useless. Programmatically specifying a custom scan config is what you want, and the OMP is not well suited to the task as it is today. If you can find the backend calls gsad (the greenbone UI) is using to directly modify cloned scan configs (i.e. unchecking an unwanted NVT) let me know. I have yet to look at the source code in detail. The problem with that implementation is that it probably circumvents OMP, and is not recommended as it may break with each release of OpenVas.
Goodluck and happy coding.

NSIS and SQLITE Integration

I am writing a installer for windows using NSIS. The installer gets few properties during installation and it needs to update one of the table in sqlite database that is bundled with the installer. Is it possible to update sqlite database file using NSIS?
It does not seem like there are any SQLite plugins.
Your options are:
Write your own plugin (included for completeness, but almost certainly not a real option)
Use nsExec to run SQLite commands via the command line interface. See discussion on NSIS forums
Write a small app to include with your installer that makes the required changes
Decision probably depends on how well you know the command line interface for SQLite vs. complexity of writing a small app to do what you want.
For #3, it would be similar to what you would do with a third party installer:
ReserveFile "myexe.exe"
...
SetOutPath $TEMP
File "myexe.exe"
ExecWait '"$TEMP\myexe.exe" /parameters"
alt option: http://sourceforge.net/projects/nsissqliteplug/
nsisSqlplugin::executeQuery "sqliteDatabase" "sql_query"
Limitations:
Currently the plugin executes only insert and update queries.

How to execute an app without elevation?

I want to invoke an updater to check for updates (not to actually do the update but only check if there is any). I would like to do this in the background and silently. If there is an update, I would ask the user for elevated permissions and run the updater with that. The checking involves reading a file in the application's directory and comparing the version found in it with the one on a website.
How can I run it without elevation for checking only? QProcess::start() fails because it needs elevated permission and ShellExecute only works if I add the "runas" verb for the same reason (which I only want if there would be actually writing in that directory i.e. I want to perform an update). I'm guessing I need to add some sort of manifest but I don't know its contents.
So it turns out that I had another bug that caused the non-elevated running branch to run in all cases. The model I described in the post works. To avoid Windows infering the need for elevated permissions, you need to add a manifest resource. (for example, if the name of your application exe contains the word "updater" it will be triggered)
The contents of the manifest are the following:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
Compiling it to your .exe depends on your compiler and environment, so I'm only showing mine: Qt Creator and mingw-gcc:
Create an rc file for the resources with the following content:
1 24 DISCARDABLE manifest.xml
Add this rc file to your .pro like this:
win32:RC_FILE = resources.rc
After this, ShellExecute without the verb paramter will run without elevation, and using "runas" will run it with elevation.
Elevation prompt appears when your application requests it, for some reason. You can control it with the application manifest. See Create and Embed an Application Manifest (UAC) article for details on how to add the manifest.
I would suggest you the following:
Separate your Updater and Update Checker, so that they're in different .EXE files.
UpdateChecker.exe requires no administrator privileges, and thus requestedExecutionLevel element of the manifest has asInvoker level.
Updater.exe requires administrator privileges because it writes updated application file into Program Files. Therefore requestedExecutionLevel element of its manifest has requireAdministrator level.
In your program you can launch UpdateChecker.exe whatever way you like. To start Updater.exe you will have to use ShellExecute; if the application has the manifest (and I strongly recommend embedding manifest) it will show UAC prompt for elevation if the application wants administrator privileges. There's no need to use runas verb.
Alternatively you can check whether update is available or not from your main application. And launch the Updater.exe only when there's a new version on the server.
Another option would be to make Updater.exe both check for update and apply it if there's one, just like you do it now. In this case Updater.exe should have asInvoker level in its manifest. When it starts, without parameters, it checks whether there's a new version on the server. If it finds newer version, it re-launches itself with administrator privileges and passes a command-line parameter, for example /doUpdate, which instructs it do perform the actual update.
In order to re-launch itself elevated, it has to use ShellExecute function and runas verb, because ShellExecute will be unable to detect automatically your Updater.exe now requires administrative privileges.
Keep in mind that the meaning of runas verb differs between Windows XP and Windows Vista/7, so you should handle this situation if you want to support previous versions of Windows. The first approach I described will work on Windows XP without additional handling.
I suggest to use one of these scenarios:
put that file in user's profile instead of application's path
copy content of that file to user's profile in case of it's in read only mode then run QProcess::start()
include that file inside .qrc file then extract it to user's profile in case of failing of read or run QProcess::start()

Resources