Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jans-tui): Saving a script as a file is not working #9979

Open
maduvena opened this issue Oct 30, 2024 · 6 comments
Open

fix(jans-tui): Saving a script as a file is not working #9979

maduvena opened this issue Oct 30, 2024 · 6 comments
Assignees
Milestone

Comments

@maduvena
Copy link
Contributor

Describe the bug
Scripts can be saved in db or as a file. The file option is not working.
Tested on Local VM, I dont know how this will translate on Cloud.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'tui'
  2. Under scripts, select any script and attempt to save the contents as a file
  3. Check db
@devrimyatar
Copy link
Contributor

devrimyatar commented Oct 31, 2024

@maduvena @pujavs I added a test script. This is what TUI sent to config-api

{
  "inum": "",
  "scriptType": "application_session",
  "enabled": false,
  "name": "test",
  "description": "test",
  "locationType": "file",
  "locationPath": "/opt/jans/python/libs/a.py",
  "programmingLanguage": "python",
  "level": 0,
  "internal": false,
  "modified": false,
  "revision": 1,
  "script": "import os\nfor i in os.listdir('/tmp'):\n    print(i)",
  "moduleProperties": [
    {
      "value1": "location_type",
      "value2": "file"
    }
  ]
}

It seems config-api ignores location. It saves to database. Here is stored script

Image

@pujavs
Copy link
Contributor

pujavs commented Oct 31, 2024

That is correct config-api custom-script functionality is entirely DB driven. This seems to be new requirement.
@yurem can we use document-store since there can be distributed env.

@yurem
Copy link
Contributor

yurem commented Oct 31, 2024

Behavior explained in this issue is opposite to initial idea of using file location type.

When we use file location type we follow next steps:

  1. Register new script type and specify it location
  2. Put script manually to file system
  3. Apply changes to script on disk
  4. Script manager do it reload on file modification within 30 seconds

Why instead of modifying script file you call config-api? This not really uses this location type in this case. It's looks like DB location type is better conform this.

@devrimyatar
Copy link
Contributor

@yurem What do you think about removing location type from TUI.

@yurem
Copy link
Contributor

yurem commented Oct 31, 2024

@devrimyatar if we remove it from TUI we can't add script with this location type. And we will loss this functionality.

@pujavs @devrimyatar what do you think about changing this part of request:

  "locationType": "file",
  "locationPath": "/opt/jans/python/libs/a.py",
  "script": "import os\nfor i in os.listdir('/tmp'):\n    print(i)",

to:

  "locationType": "file",
  "filelName": "a.py",

After getting this request config-api should build locationPath from 2 parts: script_custom_folder_path_for_file_type + fileName
This will be more secure because we not allow to run any python script from file system

Also developers still can use locationType=file

@devrimyatar
Copy link
Contributor

@yurem fileName is fine for me. It is up to @pujavs to implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants