Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9000851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:21:41+00:00 2026-06-16T00:21:41+00:00

I use JRuby in my Java application to allow users to run their scripts.

  • 0

I use JRuby in my Java application to allow users to run their scripts. The set of operations needed for normal function of the application is not big. The script should control some variables in Java code and change the process during the execution.

So I want to have an opportunity to limit the number of allowed operations. Say, I don’t want the users have an access to the file system.

f = File.new("myfile.txt", "w") 
f.puts( "Hello!" ) 
f.close

This should be forbidden.

How can I do such a setting? The only idea I have is to parse the user-script before the launch and to compare the script with white list of allowed operations.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:21:42+00:00Added an answer on June 16, 2026 at 12:21 am

    What you should do is create a white list of allowed commands. If a script is found to contain a command that is not in the white list you need to reject the entire script. A security manager as Andrew Thompson points out is a good extra layer, but it is not the end of the security layering. I don’t think running in a sandboxed applet is really going to buy you that much, since you still have to determine if the script was valid to begin with.

    WHITE LIST EXAMPLE

    Typically when you generate a white list there are a limited number of options/commands you want users to be able to choose from and the rest become discarded. you would create some enumeration or final data structure (to minimize its ability to be modified during runtime by malicious programs). If you wanted users to only have the option to invoke your function foo and not bar you could write something like this, which is completely primitive but illustrates the concept:

    class WhiteList  
    {  
         allowedCommands = ["foo"];  
    }  
    

    and in your main something like this:

    class Main  
    {  
         for(Command command in userInput)  
         { 
               if(command not in allowedCommands)  
               {  
                    log security message;  
                    continue/break
               }  
         }  
    }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Description: If we use java objects jruby get permgen too: System.out.println(Initialazing..); //Spring applicaton context
I'm trying to use JRuby in a custom application, and I don't seem to
I am writing a library in Java so I can use it in JRuby
Can I use other JVM languages besides Java (e.g. jruby, jython, clojure) to program
As far as I understand JRuby, it is perfectly possible to use Java class
I would like to use JRuby to run a script which populates a database.
I've created a simple 'hello' type JRuby application and use Warbler to WAR up
I'm trying to extend Lucene's Analyzer from JRuby and use it from java. A
With JRuby, you can make use of Java libraries in Ruby. Is there the
I have a Java servlet website, but does not use any frameworks like Spring

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.