Issues (25)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

lib/Admin/Settings.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 * The dashboard-specific functionality of the plugin.
5
 *
6
 * @link       http://example.com
7
 * @since      1.0.0
8
 *
9
 * @package    RedmineEmbed
10
 * @subpackage RedmineEmbed/Admin
11
 */
12
13
namespace logoscon\WP\RedmineEmbed\Admin;
14
15
use logoscon\WP\RedmineEmbed\Plugin;
16
17
/**
18
 * The dashboard-specific functionality of the plugin.
19
 *
20
 * Defines the plugin name, version, and two examples hooks for how to
21
 * enqueue the dashboard-specific stylesheet and JavaScript.
22
 *
23
 * @package    RedmineEmbed
24
 * @subpackage RedmineEmbed/Admin
25
 * @author     log.OSCON, Lda. <[email protected]>
26
 */
27
class Settings {
28
29
    /**
30
     * The plugin's instance.
31
     *
32
     * @since  1.0.0
33
     * @access private
34
     * @var    Plugin $plugin This plugin's instance.
35
     */
36
    private $plugin;
37
38
    /**
39
     * Initialize the class and set its properties.
40
     *
41
     * @since 1.0.0
42
     * 
43
     * @param Plugin $plugin This plugin's instance.
44
     */
45
    public function __construct( Plugin $plugin ) {
46
        $this->plugin = $plugin;
47
    }
48
49
    /**
50
     * Register the menu entry for the plugin's settings page.
51
     *
52
     * @since 1.1.0
53
     */
54
    public function menu() {
55
        \add_options_page(
56
            __( 'Redmine Embed', 'redmine-embed' ),
57
            __( 'Redmine Embed', 'redmine-embed' ),
58
            'manage_options',
59
            $this->plugin->get_name(),
60
            array( $this, 'page' )
61
        );
62
    }
63
64
    /**
65
     * Register plugin settings.
66
     *
67
     * @uses add_settings_field()
68
     * @uses add_settings_section()
69
     * @uses register_setting()
70
     *
71
     * @since   1.0.0
72
     */
73
    public function add() {
74
        \register_setting(
75
            $this->plugin->get_name(),
76
            $this->plugin->get_option_key(),
77
            array( $this, 'validate' )
78
        );
79
80
        // Default plugin settings:
81
        \add_settings_section( 'default', '', false, $this->plugin->get_name() );
82
83
        \add_settings_field(
84
            'root_url',
85
            __( 'Redmine URL', 'redmine-embed' ),
86
            array( $this, 'field_root_url' ),
87
            $this->plugin->get_name()
88
        );
89
90
        \add_settings_field(
91
            'api_key',
92
            __( 'API Key', 'redmine-embed' ),
93
            array( $this, 'field_api_key' ),
94
            $this->plugin->get_name()
95
        );
96
    }
97
98
    /**
99
     * Validates and updates CAS server plugin settings.
100
     *
101
     * @param  array $input Unvalidated input arguments when settings are updated.
102
     *
103
     * @return array        Validated plugin settings to be saved in the database.
104
     *
105
     * @since 1.1.0
106
     */
107
    public function validate( $input ) {
108
        $options = $this->plugin->get_option();
109
110
        $options['root_url'] = \esc_url_raw( $input['root_url'] );
111
        $options['api_key']  = $input['api_key'];
112
113
        return $options;
114
    }
115
116
    /**
117
     * Displays the CAS server settings page in the dashboard.
118
     *
119
     * @uses \_e()
120
     * @uses \do_settings_sections()
121
     * @uses \settings_fields()
122
     * @uses \submit_button()
123
     *
124
     * @since 1.1.0
125
     */
126
    public function page() {
127
        ?>
128
        <div class="wrap">
129
            <h2><?php \_e( 'Redmine Embed', 'redmine-embed' ); ?></h2>
130
131
            <p><?php \_e( 'Configure how Redmine is integrated on this site.', 'redmine-embed' ); ?></p>
132
133
            <form action="options.php" method="POST">
134
                <?php \do_settings_sections( $this->plugin->get_name() ); ?>
135
                <?php \settings_fields( $this->plugin->get_name() ); ?>
136
                <?php \submit_button(); ?>
137
            </form>
138
        </div>
139
        <?php
140
    }
141
142
    /**
143
     * Display the configuration field for the Redmine root URL.
144
     *
145
     * @uses \esc_url()
146
     *
147
     * @since 1.0.0
148
     */
149 View Code Duplication
    public function field_root_url() {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
150
        $root_url = \esc_url( $this->plugin->get_option( 'root_url' ) );
151
152
        ?>
153
        <input name="<?php echo $this->plugin->get_option_key(); ?>[root_url]" type="text" value="<?php echo $root_url; ?>"
154
             id="root_url" class="regular-text" aria-describedby="root_url-description">
155
        <p id="root_url-description" class="root_url description">
156
            <?php _e( 'Enter the address for your Redmine install.', 'redmine-embed' ); ?>
157
        </p>
158
        <?php
159
    }
160
161
    /**
162
     * Display the configuration field for the Redmine API key.
163
     *
164
     * @uses \esc_url()
165
     *
166
     * @since 1.0.0
167
     */
168 View Code Duplication
    public function field_api_key() {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
169
        $api_key = \sanitize_text_field( $this->plugin->get_option( 'api_key' ) );
170
171
        ?>
172
        <input name="<?php echo $this->plugin->get_option_key(); ?>[api_key]" type="text" value="<?php echo $api_key; ?>"
173
             id="api_key" class="regular-text" aria-describedby="api_key-description">
174
        <p id="api_key-description" class="api_key description">
175
            <?php _e( 'Enter your Redmine API key. It may be found on the right-hand pane of your account page.', 'redmine-embed' ); ?>
176
        </p>
177
        <?php
178
    }
179
180
}