Create a CLI application - gd-99/symbiogd GitHub Wiki

Page translated to English by Jack

You can create an application for the command line using either Javascript or PHP. However, it is advisable to use Javascript when possible for security reasons.

Using PHP

Watch Out! Be especially careful when creating applications in PHP. Indeed, any user (connected or not) can execute commands, it will be necessary to ensure their permissions check if changes are made ​​to the system.

Hello World

To create an application written in PHP command line, simply create a / usr / bin / php frontend.

In this file, simply write the code of your order. Here is a Hello World implementation!:

(/usr/bin/hello-world.php)

Security

It is very important to consider safety when creating PHP applications. Indeed, anyone can execute commands. In the case of a PHP script, the task of verifying whether the user is authorized or not to perform an action (delete files, create, add a user, etc ...) is left to the script. This means that you must conduct audits on the rights of the user when you create a PHP script.

Here's how to check if the user has the right to perform an action. Here, it checks whether the user has the right to write to the folder / (root of webos).

// Check permissions // Check the user rights "file.write" on the record "/" $ This -> guardian -> controlArgAuth ('file.write', '/', $ processAuths)

// Another example is verified that the user can list other users and read their characteristics (name, e-mail, etc ...) $ This -> guardian -> controlAuth ('user.read', $ processAuths) ?>

Work in Progess, Expanding soon