spine icon indicating copy to clipboard operation
spine copied to clipboard

Spine should see if script to be executed is executable

Open netniV opened this issue 4 years ago • 1 comments

Describe the bug If a script is not actually executable, spine fails with a warning about improper data.

Expected behavior It should know that the script is not executable and therefore properly report this.

netniV avatar Sep 25 '21 00:09 netniV

This is mostly for POLLER_SCRIPT methods but it may be worth including in poller.php/cmd.php too for their scripts.

netniV avatar Sep 25 '21 00:09 netniV

The main issue is breaking up the command into the executable portion and the command parameters. If we have the executable portion separately, it would make life easier but we don't.

netniV avatar Jan 06 '23 17:01 netniV

If we did have a separate executable string, then we could have done it using something like:

if (stat(file, &sb) == 0 && sb.st_mode & S_IXUSR) {
    popen / nft_open
} else {
   // report
}

netniV avatar Jan 06 '23 17:01 netniV

I was giving this one some thought @netniV, maybe this needs to be optional, as a data input method that does echo /some/file.dat could fail on two parts. First there is no path to echo, and we would have to do a which followed by a check for file exists. You see the rabbit hole?

TheWitness avatar Jul 30 '23 12:07 TheWitness

You wouldn't have a template doing a simple echo. As far as I am aware, they always call a script or executable

netniV avatar Jul 30 '23 13:07 netniV

Good point, but here is a more reasonable example, one that I actually used in the old days:

  1. In cron, you create a file abc.txt that includes some data you want to use in Cacti. Output could look like "name1:value1 name2:value2"
  2. You cat input method does cat abc.txt

There are two problems here:

  1. First, cat does not need a path depending on your spine option, so to validate it, you have to first do a which
  2. Second, you don't know if the second attributed is a file to cat or some option unless you start implementing some AI in Cacti

So, to fully cover the is the path executable does not really solve the problem entirely. You have to dig down deep to get to the bottom of the rabbit hole.

TheWitness avatar Jul 30 '23 14:07 TheWitness

Okay, fixed then.

TheWitness avatar Jul 30 '23 15:07 TheWitness

KNOWN ISSUE - If you call command without a path, starting in spine 1.2.25, those commands will fail. This actually fixes a security issue if you think about it too.

TheWitness avatar Jul 30 '23 15:07 TheWitness