Issues (399)

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.

tests/extensions/DMSSiteTreeExtensionTest.php (6 issues)

Labels
Severity

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
class DMSSiteTreeExtensionTest extends SapphireTest
4
{
5
    protected static $fixture_file = 'dms/tests/dmstest.yml';
6
7
    protected $requiredExtensions = array(
8
        'SiteTree' => array('DMSSiteTreeExtension')
9
    );
10
11
    /**
12
     * Ensure that setting the configuration property "documents_enabled" to false for a page type will prevent the
13
     * CMS fields from being modified.
14
     *
15
     * Also ensures that a correctly named Document Sets GridField is added to the fields in the right place.
16
     *
17
     * Note: the (1) is the number of sets defined for this SiteTree in the fixture
18
     *
19
     * @dataProvider documentSetEnabledConfigProvider
20
     */
21
    public function testCanDisableDocumentSetsTab($configSetting, $assertionMethod)
22
    {
23
        Config::inst()->update('SiteTree', 'documents_enabled', $configSetting);
24
        $siteTree = $this->objFromFixture('SiteTree', 's2');
25
        $this->$assertionMethod($siteTree->getCMSFields()->fieldByName('Root.DocumentSets.DocumentSets'));
26
    }
27
28
    /**
29
     * @return array[]
30
     */
31
    public function documentSetEnabledConfigProvider()
32
    {
33
        return array(
34
            array(true, 'assertNotNull'),
35
            array(false, 'assertNull')
36
        );
37
    }
38
39
    /**
40
     * Tests for the Document Sets GridField.
41
     *
42
     * Note: the (1) is the number of sets defined for this SiteTree in the fixture
43
     */
44
    public function testDocumentSetsGridFieldIsCorrectlyConfigured()
45
    {
46
        Config::inst()->update('SiteTree', 'documents_enabled', true);
47
        $siteTree = $this->objFromFixture('SiteTree', 's2');
48
        $gridField = $siteTree->getCMSFields()->fieldByName('Root.DocumentSets.DocumentSets');
49
50
        $this->assertInstanceOf('GridField', $gridField);
0 ignored issues
show
The method assertInstanceOf() does not seem to exist on object<DMSSiteTreeExtensionTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
51
        $this->assertTrue((bool) $gridField->hasClass('documentsets'));
0 ignored issues
show
The method assertTrue() does not seem to exist on object<DMSSiteTreeExtensionTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
52
    }
53
54
    /**
55
     * Ensure that a page title can be retrieved with the number of related documents it has (across all document sets).
56
     *
57
     * See fixtures for relationships that define this result.
58
     */
59
    public function testGetTitleWithNumberOfDocuments()
60
    {
61
        $siteTree = $this->objFromFixture('SiteTree', 's1');
62
        $this->assertSame('testPage1 has document sets (5)', $siteTree->getTitleWithNumberOfDocuments());
0 ignored issues
show
The method assertSame() does not seem to exist on object<DMSSiteTreeExtensionTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
63
    }
64
65
    /**
66
     * Ensure that documents marked as "embargo until publish" are unmarked as such when a page containing them is
67
     * published
68
     */
69
    public function testOnBeforePublishUnEmbargoesDocumentsSetAsEmbargoedUntilPublish()
70
    {
71
        $siteTree = $this->objFromFixture('SiteTree', 's7');
72
        $siteTree->doPublish();
73
74
        // Fixture defines this page as having two documents via one set
75
        foreach (array('embargo-until-publish1', 'embargo-until-publish2') as $filename) {
76
            $this->assertFalse(
0 ignored issues
show
The method assertFalse() does not seem to exist on object<DMSSiteTreeExtensionTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
77
                (bool) $siteTree->getAllDocuments()
78
                    ->filter('Filename', 'embargo-until-publish1')
79
                    ->first()
80
                    ->EmbargoedUntilPublished
81
            );
82
        }
83
        $this->assertCount(0, $siteTree->getAllDocuments()->filter('EmbargoedUntilPublished', true));
0 ignored issues
show
The method assertCount() does not seem to exist on object<DMSSiteTreeExtensionTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
84
    }
85
86
    /**
87
     * Ensure that document sets that are assigned to pages to not show up in "link existing" autocomplete
88
     * search results
89
     */
90
    public function testGetRelatedDocumentsForAutocompleter()
91
    {
92
        $page = $this->objFromFixture('SiteTree', 's1');
93
        $gridField = $page->getCMSFields()->fieldByName('Root.DocumentSets.DocumentSets');
94
        $this->assertInstanceOf('GridField', $gridField);
0 ignored issues
show
The method assertInstanceOf() does not seem to exist on object<DMSSiteTreeExtensionTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
95
96
        $autocompleter = $gridField->getConfig()->getComponentByType('GridFieldAddExistingAutocompleter');
97
        $jsonResult = $autocompleter->doSearch(
98
            $gridField,
99
            new SS_HTTPRequest('GET', '/', array('gridfield_relationsearch' => 'Document Set'))
100
        );
101
102
        $this->assertContains('Document Set not linked', $jsonResult);
103
        $this->assertNotContains('Document Set 1', $jsonResult);
104
    }
105
}
106