Issues (407)

Security Analysis    not enabled

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.

plugins/actions/twitter/plugins.php (3 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
 * references - MODULE FOR XOOPS
5
 * Copyright (c) Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
6
 *
7
 * You may not change or alter any portion of this comment or credits
8
 * of supporting developers from this source code or any supporting source code
9
 * which is considered copyrighted (c) material of the original comment or credit authors.
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 *
14
 * @copyright         Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
15
 * @license           http://www.fsf.org/copyleft/gpl.html GNU public license
16
 * @package           references
17
 * @author            Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
18
 *
19
 * ****************************************************************************
20
 */
21
22
/**
23
 * Plugin chargé de publier sur twitter des messages pour indiquer :
24
 * 1/ La création d'un nouveau produit
25
 * 2/ La publication d'un nouvel article
26
 *
27
 * @since 1.81
28
 */
29
class referencesTwitterAction extends references_action
30
{
31
    public function registerEvents()
32
    {
33
        /**
34
         * La liste des évènements traités par le plugin se présente sous la forme d'un tableau compposé comme ceci :
35
         *
36
         * Indice    Signification
37
         * ----------------------
38
         *    0        Evènement sur lequel se raccrocher (voir class/references_plugins.php::EVENT_ON_PRODUCT_CREATE
39
         *    1        Priorité du plugin (de 1 à 5)
40
         *    2        Script Php à inclure
41
         *    3        Classe à instancier
42
         *    4        Méthode à appeler
43
         */
44
        $events   = array();
45
        $events[] = array(
46
            references_plugins::EVENT_ON_REFERENCE_CREATE,
47
            references_plugins::EVENT_PRIORITY_1,
48
            basename(__FILE__),
49
            __CLASS__,
50
            'fireNewReference'
51
        );
52
        $events[] = array(
53
            references_plugins::EVENT_ON_CATEGORY_CREATE,
54
            references_plugins::EVENT_PRIORITY_1,
55
            basename(__FILE__),
56
            __CLASS__,
57
            'fireNewCategory'
58
        );
59
        return $events;
60
    }
61
62
    /**
63
     * Méthode générique chargée d'envoyer un texte sur un compte twitter avec une url
64
     *
65
     * @param string $textToSend Le texte à envoyer
66
     * @param string $mask       Le masque à utiliser
67
     * @param string $elementUrl L'url de l'élément concerné
68
     * @return string                Le texte qui a été envoyé à twitter
69
     */
70
    private function sendTextToTwitter($textToSend, $mask, $elementUrl)
71
    {
72
        if (!defined('REFERENCES_TWITTER_PLUGIN_PATH')) {
73
            define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH . 'actions' . DIRECTORY_SEPARATOR . 'twitter' . DIRECTORY_SEPARATOR);
74
        }
75
        require_once REFERENCES_TWITTER_PLUGIN_PATH . 'config.php';
76
        //require_once REFERENCES_TWITTER_PLUGIN_PATH.'twitter.php';
77
        require_once REFERENCES_TWITTER_PLUGIN_PATH . 'Twitter.class.php';
78
        require_once REFERENCES_TWITTER_PLUGIN_PATH . 'bitly.class.php';
79
        if (REFERENCES_BITLY_LOGIN == '') {
80
            return '';
81
        }
82
        $sentText    = '';
0 ignored issues
show
$sentText is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
83
        $bitly       = new Bitly(REFERENCES_BITLY_LOGIN, REFERENCES_BITLY_API_KEY);
84
        $shortUrl    = $bitly->shortenSingle($elementUrl);
85
        $searches    = array('[itemname]', '[url]');
86
        $replaces    = array($textToSend, $shortUrl);
87
        $sentText    = str_replace($searches, $replaces, $mask);
88
        $totalLength = strlen($sentText);
89
        if ($totalLength > REFERENCES_TWITTER_TWIT_MAX_LENGTH) {
90
            $tooLongOf = $totalLength - REFERENCES_TWITTER_TWIT_MAX_LENGTH;
91
            $searches  = array('[itemname]', '[url]');
92
            $replaces  = array(substr($textToSend, 0, strlen($textToSend) - $tooLongOf), $shortUrl);
93
            $sentText  = str_replace($searches, $replaces, $mask);
94
        }
95
        if (trim($sentText) != '') {
96
            //          $twitter = new Twitter(REFERENCES_TWITTER_USERNAME, REFERENCES_TWITTER_PASSWORD);
97
            //          $twitter->setUserAgent('references');
98
            //          $twitter->updateStatus($sentText);
99
            $tweet = new Twitter(REFERENCES_TWITTER_USERNAME, REFERENCES_TWITTER_PASSWORD);
100
            $tweet->update($sentText);
101
        }
102
        return $sentText;
103
    }
104
105
    /**
106
     * Méthode appelée pour indiquer qu'une nouvelle référence a été publié
107
     *
108
     * @param object $parameters La référence qui vient d'être publiée
109
     * @return void
110
     */
111 View Code Duplication
    public function fireNewReference($parameters)
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...
112
    {
113
        if (!defined('REFERENCES_TWITTER_PLUGIN_PATH')) {
114
            define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH . 'actions' . DIRECTORY_SEPARATOR . 'twitter' . DIRECTORY_SEPARATOR);
115
        }
116
        require_once REFERENCES_TWITTER_PLUGIN_PATH . 'config.php';
117
        $reference = $parameters['reference'];
118
        $this->sendTextToTwitter(utf8_encode($reference->getVar('article_title', 'n')), utf8_encode(REFERENCES_TWITTER_NEW_REFERENCE_INTRO), $reference->getUrl());
119
    }
120
121
    /**
122
     * Méthode appelée pour indiquer qu'une nouvelle catégorie de références a été créée
123
     *
124
     * @param object $parameters La catégorie qui vient d'être publiée
125
     * @return void
126
     */
127 View Code Duplication
    public function fireNewCategory($parameters)
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...
128
    {
129
        if (!defined('REFERENCES_TWITTER_PLUGIN_PATH')) {
130
            define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH . 'actions' . DIRECTORY_SEPARATOR . 'twitter' . DIRECTORY_SEPARATOR);
131
        }
132
        require_once REFERENCES_TWITTER_PLUGIN_PATH . 'config.php';
133
        if (trim(REFERENCES_TWITTER_NEW_CATEGORY_INTRO) != '') {
134
            $category = $parameters['category'];
135
            $this->sendTextToTwitter(utf8_encode($category->getVar('category_title', 'n')), utf8_encode(REFERENCES_TWITTER_NEW_CATEGORY_INTRO), $category->getUrl());
136
        }
137
    }
138
}
139