r1 - 2002-08-11 - 16:25:51 - TWikiGuestYou are here: NTP >  TWiki Web > ConditionalPlugin
NTP users are strongly urged to take immediate action to ensure that their NTP daemons are not susceptible to being used in distributed denial-of-service (DDoS) attacks. Please also take this opportunity to defeat denial-of-service attacks by implementing Ingress and Egress filtering through BCP38.

ntp-4.2.8p13 was released on 07 March 2019. It addresses 1 medium-severity security issue in ntpd, and provides 17 non-security bugfixes and 1 other improvements over 4.2.8p12.

Please see the NTP Security Notice for vulnerability and mitigation details.

Are you using Autokey in production? If so, please contact Harlan - he's got some questions for you.

ConditionalPlugin

This is an alpha version and is still under development. See ConditionalPluginDev for discussion.

This plugin adds the ability to do simple, not nested, conditional rendering in topics.

It attempts to do this in a relatively secure manner by applying the following security measures:

  • restrictive filter for the expression of 'scalar operator scalar'
    • where 'operator' must be one of =,>,<,<,>=,!=,eq,ne,gt,lt,le,ge,<=>,cmp,=~,!~
    • the list of valid operators is hardcoded and cannot be changed by users
    • and 'scalar' is a string consisting of alphanumeric characters + underscore with no whitespace (\w)
  • evaluation of the expression in a sandbox, created with the Safe module.
    • only the opcodes in the :base_core set are allowed (see Opcode)

More sophisticated constructs (like support for range-conditions or nested constructs) may appear in future revisions, if and when the need for them arises.

Syntax Rules

IF{ operator="1" scalar="1" }: Empty expression text %ELSE% text %ENDIF%

  • the '%ELSE% text' clause is optional

  • Note: at the moment nested if-else-endif constructs are not supported.

Examples

The following example prints something dependent on the topicname (can be usefull in templates)

IF{ "%TOPIC% eq WebHome" }: Syntax error in '%TOPIC% eq WebHome' at '%TOPIC% eq WebHome' This is the WebHome topic %ELSE% This is NOT the WebHome topic %ENDIF%

Result

*

IF{ ConditionalPlugin="1" WebHome="1" eq="1" }: Empty expression This is the WebHome topic %ELSE% This is NOT the WebHome topic %ENDIF%

A different approach, without the 'else' clause:

* This is

IF{ "%TOPIC% ne WebHome" }: Syntax error in '%TOPIC% ne WebHome' at '%TOPIC% ne WebHome' NOT %ENDIF% the WebHome topic

Which of course als results in:

  • This is

IF{ ConditionalPlugin="1" WebHome="1" ne="1" }: Empty expression NOT %ENDIF% the WebHome topic

Or:

IF{ "%GMTIME{\"$hour\"" }: Syntax error in '%GMTIME{"$hour"' at '%GMTIME{"$hour"' > 18 }% Good evening folks!! %ELSE% Good day folks!! %ENDIF%

Which results in:

  • Good evening folks!! %ELSE% Good day folks!! %ENDIF%

ConditionalPlugin Global Settings

Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%, i.e. %INTERWIKIPLUGIN_SHORTDESCRIPTION%

  • One line description, is shown in the TextFormattingRules topic:
    • Set SHORTDESCRIPTION = Adds conditional rendering (if/then/else)

  • Debug plugin: (See output in data/debug.txt)
    • Set DEBUG = 0

Plugin Installation Instructions

Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running.

  • Download the ZIP file from the Plugin web (see below)
  • Unzip ConditionalPlugin.zip in your twiki installation directory. Content:
    File: Description:
    data/TWiki/ConditionalPlugin.txt Plugin topic
    data/TWiki/ConditionalPlugin.txt,v Plugin topic repository
    lib/TWiki/Plugins/ConditionalPlugin.pm Plugin Perl module
  • See the examples above to check if the installation was successful.

Plugin Info

Plugin Author: JeroenVanDongen
Plugin Version: 10 Aug 2002 (V1.000)
Change History:  
10 Aug 2002: Initial version
10 Aug 2002: Improved regexp to deal with multi-line constructs
11 Aug 2002: Added lazy-loading for Safe.pm
CPAN Dependencies: none
Other Dependencies: Safe.pm (part of Perl 5.005_3 and up
Perl Version: 5.005
Plugin Home: http://TWiki.org/cgi-bin/view/Plugins/ConditionalPlugin
Feedback: http://TWiki.org/cgi-bin/view/Plugins/ConditionalPluginDev

Related Topics: TWikiPreferences, TWikiPlugins

-- JeroenVanDongen - 10 Aug 2002

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r1 | More topic actions
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding NTP? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.ConditionalPlugin