Skip to content

Commit

Permalink
Merge pull request #12 from myxcel/development
Browse files Browse the repository at this point in the history
Adapted SE to 'javascript' for Rhino
  • Loading branch information
myxcel authored Jan 6, 2025
2 parents 8739111 + a3efd3a commit d9693fd
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 39 deletions.
5 changes: 5 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# These are supported funding model platforms

github: [myxcel]
liberapay: myxcel
buy_me_a_coffee: myxcel
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
.songe.key*
.songe.trust*
config.cfg
version.txt

# Build files
release/
build/
out/
lunasql.iml

# Database
base/
Expand Down
40 changes: 13 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*LunaSQL* - a fair SQL shell client
===================================

<!-- TABLE OF CONTENTS -->
<!-- TABLE OF CONTENTS -->
<details>
<summary>Table of Contents</summary>
<ol>
Expand All @@ -17,12 +17,12 @@
</ol>
</details><br />

[![Java CI](https://github.com/auditum-mpa/lunasql/actions/workflows/ant.yml/badge.svg)](https://github.com/auditum-mpa/lunasql/actions/workflows/ant.yml) -
[![Discuss](https://img.shields.io/badge/version-4.9.1.3-green)](https://github.com/auditum-mpa/lunasql/releases/tag/4.9.3.0)
[![Releases](https://img.shields.io/github/downloads/auditum-mpa/lunasql/total.svg)](https://github.com/auditum-mpa/lunasql/releases/latest) -
[![Discuss](https://img.shields.io/badge/discuss-here-magenta)](https://github.com/auditum-mpa/lunasql/discussions)
[![Wiki](https://img.shields.io/badge/consult-wiki-blue)](https://github.com/auditum-mpa/lunasql/wiki)
[![Issue](https://img.shields.io/badge/report-issue-orange)](https://github.com/auditum-mpa/lunasql/issues)
[![Java CI](https://github.com/myxcel/lunasql/actions/workflows/ant.yml/badge.svg)](https://github.com/myxcel/lunasql/actions/workflows/ant.yml) -
[![Latest](https://img.shields.io/badge/version-latest-green)](https://github.com/myxcel/lunasql/releases/tag/latest)
[![Release](https://img.shields.io/github/downloads/myxcel/lunasql/total.svg)](https://github.com/myxcel/lunasql/releases/latest) -
[![Discuss](https://img.shields.io/badge/discuss-here-magenta)](https://github.com/myxcel/lunasql/discussions)
[![Wiki](https://img.shields.io/badge/consult-wiki-blue)](https://github.com/myxcel/lunasql/wiki)
[![Issue](https://img.shields.io/badge/report-issue-orange)](https://github.com/myxcel/lunasql/issues)

## About the project

Expand Down Expand Up @@ -52,6 +52,8 @@ LunaSQL is released as a jar file, which can be run using [H2 Database driver](h
java lunasql.Main --type=H2DB --name=path/to/base/MyDB --user=sa --password="" --console
```

**Important note about the Nashorn JSR-223 script engine**: since Java 15, the Nashorn script engine (Javascript eveluation engine) was removed from the JRE distribution. As result, in order to evaluate control commands or javascript libraries, it is now mandatory to add an external library, like [Rhino](https://github.com/mozilla/rhino) or [Nashorn](https://github.com/openjdk/nashorn). Other JSR-223 engines like [beanshell](https://github.com/beanshell/beanshell) [Jython](https://github.com/jython/jython), [JRuby](https://github.com/jruby/jruby) or [clojure](https://github.com/clojure/clojure) can also fit for evaluations.

To build the distribution, just run the [ant](https://ant.apache.org) task (you may have to adapt the `path id="classpath"` entry):

```
Expand All @@ -60,34 +62,18 @@ ant dist

## How to contribute

Any help will be greatly appreciated! You can contribute by using the application and testing it, [reporting new issues](https://github.com/auditum-mpa/lunasql/issues). You can also try to work on [good first issues](https://github.com/auditum-mpa/lunasql/contribute). Don't forget that the [Discussions page](https://github.com/auditum-mpa/lunasql/discussions) warmly welcomes you to say hello or discuss about new ideas, questions...
Any help will be greatly appreciated! You can contribute by using the application and testing it, [reporting new issues](https://github.com/myxcel/lunasql/issues). You can also try to work on [good first issues](https://github.com/myxcel/lunasql/contribute). Don't forget that the [Discussions page](https://github.com/myxcel/lunasql/discussions) warmly welcomes you to say hello or discuss about new ideas, questions...

## External libraries

See the [src/lunasql/doc/libraries.txt](https://github.com/auditum-mpa/lunasql/blob/master/src/lunasql/doc/libraries.txt). Thank you to all libraries contributors for your good job!
See the [src/lunasql/doc/libraries.txt](https://github.com/myxcel/lunasql/blob/master/src/lunasql/doc/libraries.txt). Thank you to all libraries contributors for your good job!

## Checking integrity

First, commits are signed with PGP key fingerprint `6F9F 349C D9DB 0B1A A0EC B6DE 2EA0 CCE6 2860 3945` and are automatically verified by GitHub. Additionally, LunaSQL release library `lunasql.x.x.x.jar` file is signed by [Keybase PGP key](https://keybase.io/espritlibredev/key.asc) (fingerprint `AA77 7903 6281 D0E9 209B E8B9 2627 39EB A36C EB3E`).

To verify this release library file, simply type the following command in the download directory:

```bash
keybase pgp verify -i lunasql-x.x.x.jar -d lunasql-x.x.x.jar.asc
```

**or** if you prefer to use GnuPG:

```bash
curl https://keybase.io/espritlibredev/key.asc | gpg --import && \
gpg --verify lunasql-x.x.x.jar.asc lunasql-x.x.x.jar
```
First, commits are signed with PGP key fingerprint `466F B094 B95C 3589` (until 2023: `2EA0 CCE6 2860 3945`) and are automatically verified by GitHub.

## License

LunaSQL is distributed under the CeCILL License. See the [french](http://cecill.info/licences/Licence_CeCILL_V2.1-fr.html) or [english](http://cecill.info/licences/Licence_CeCILL_V2.1-en.html) versions for further details.

If you like LunaSQL, please pay me a :coffee: coffee ([Stellar](https://www.stellar.org/) _espritlibredev*keybase.io_)

Enjoy!

If you like LunaSQL, please remember it's maintained in my free time, and... [buy me a coffee](https://gist.github.com/myxcel/bcbddb4a2429e2fc84dc5f813ad5a87e#file-support-md) ❤️
17 changes: 14 additions & 3 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
## Security Policy
# Security policy

If you discover a security vulnerability, please contact me by [Keybase](https://keybase.io/espritlibredev) or by [Matrix](https://matrix.org/) (@espritlibredev:nitro.chat). By e-mail, please use my PGP [key](https://keybase.io/espritlibredev/key.asc). Please do not post the vulnerability publicly, as it could be exploited by a hacker.
## Supported versions

Thank you.
LunaSQL is supported on a best endeavors basis. Patches will be applied to the *latest version* rather than retroactively to other versions. Please make sure you always have the [latest release](https://github.com/myxcel/lunasql/releases/latest).

## Reporting a vulnerability

Whilst I aim to write clean and secure code free from bugs and security issues, I am not perfect, this project is written in my spare time and it relies on external libraries.

In many scenarios, the most appropriate way to report a vulnerability is to [raise an issue](https://github.com/myxcel/lunasql/issues/new/choose) describing the problem in as much details as possible.

This will obviously be *public*. If you feel that the vulnerability is significant enough to warrant a private disclosure, please create an [advisory](https://github.com/myxcel/lunasql/security/advisories/new), or report it by email (base64-encoded `aXNzdWVAbWljYWVsLnVuYm94LmF0`, decode it [here](https://it-tools.tech/base64-string-converter)).

If you choose to send an e-mail, you can decide to encrypt with my key [466F B094 B95C 3589](https://gist.githubusercontent.com/myxcel/8dc88878af2eea1d02e52ae55c694fc0/raw/myxcel-466FB094B95C3589.asc).

Thank you very much for your contribution! Your account will be credited in the acknowledgments section of this repository.
4 changes: 3 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
<property name="build" location="build"/>
<property name="dist" location="release"/>
<property name="docs" location="docs"/>
<property name="version" value="4.9.3"/>
<property name="version" value="4.9.4"/>
<property name="main" value="lunasql.Main"/>

<path id="classpath">
<fileset dir="../../lib">
<include name="rhino-1.7.15.jar" />
<include name="rhino-engine-1.7.15.jar" />
<include name="h2-1.4.200.jar" />
<include name="jansi-1.11.jar" />
<include name="javamail-1.5.jar" />
Expand Down
10 changes: 5 additions & 5 deletions src/lunasql/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public class Config {

/* À propos */
public static final String APP_VERSION_NAME = "Quincella";
public static final String APP_VERSION_NUM = "4.9.3.0"; // modèle: n.n.n.n
public static final String APP_DT_REVISION = "28 octobre 2022";
public static final String APP_VERSION_NUM = "4.9.4.0"; // modèle: n.n.n.n
public static final String APP_DT_REVISION = "6 janvier 2025";
public static final String APP_AUTHOR_NAME = "Micaël Paganotto";
public static final String APP_AUTHOR_EMAIL = "keybase.io/espritlibredev";
public static final String APP_AUTHOR_PGP = "aa77 7903 6281 d0e9 209b e8b9 2627 39eb a36c eb3e";
public static final String APP_AUTHOR_EMAIL = "libre@micael.unbox.org";
public static final String APP_AUTHOR_PGP = "0776 05A3 706E 76FE B6A8 E237 466F B094 B95C 3589";

/* Comportement général */
public static final int CF_MAX_CALL_DEEP = 200; // profondeur maximale pour ALIAS et EXEC
Expand All @@ -30,7 +30,7 @@ public class Config {
public static final boolean CT_EXIT_ON_ERROR = true; // sortie sur erreur
public static final int CT_CONST_EDIT = 2; // constantes ':' éditables en console
public static final int CT_SQL_UPDATE = 1; // exécution de code SQL de mise-à-jour
public static final String CT_EVAL_ENGINE = "js"; // moteur d'évaluation par défaut
public static final String CT_EVAL_ENGINE = "javascript"; // moteur d'évaluation par défaut

/* Contexte d'exécution : répertoires de scripts par défaut (séparateur : ou ; selon plateforme) */
public static final String CT_SCRIPTS_PATH = "scripts" + File.pathSeparator + ".";
Expand Down
2 changes: 1 addition & 1 deletion src/lunasql/Console.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import lunasql.lib.Tools;
import lunasql.sql.SQLCnx;
import lunasql.val.Valeur;
//TODO : passer donc en Jline 3 https://github.com/jline/jline3
//TODO : passer donc en Jline 3 https://github.com/jline/jline3, oublié, trop bizarre.

public class Console {

Expand Down
6 changes: 4 additions & 2 deletions src/lunasql/lib/Contexte.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ public final class Contexte {
private final HashMap<String, String> tmpvars; // var. $_n, $_l, $1, $2...
private final HashMap<String, Class<Instruction>> plugins; // liste des plugins chargés
private final HashMap<Integer, EvalEngine> engines; // liste des engines chargés
//private final ScriptEngineManager engineman; // old manager des engines
private ScriptContext enginejscnt; // contexte pour js
private ScriptEngine evaleng; // engine courant
private Lecteur lecteur; // lecteur courant
Expand Down Expand Up @@ -465,7 +464,7 @@ public Contexte(boolean color) throws IOException {

// Lecture du fichier ressources de fonctions Javascript
try {
ScriptEngine se = getEvalEngine("js");
ScriptEngine se = getEvalEngine("javascript");
if (se != null) se.eval(new InputStreamReader(getClass().getResourceAsStream("/lunasql/misc/init-se.js")));
}
catch (ScriptException ex) {
Expand Down Expand Up @@ -1436,6 +1435,9 @@ public int getRowMaxNumber(int lng){
public Object evaluerExpr(String expr) throws ScriptException {
if (expr == null || expr.isEmpty()) return null;
if (evaleng != null) return evaleng.eval(Tools.removeBracketsIfAny(expr).trim());

// TODO: Si aucun SE disponible
//erreur("Contexte", "Aucun moteur d'évaluation disponible", lng);
return null;
}

Expand Down

0 comments on commit d9693fd

Please sign in to comment.