Issues (34)

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.

Unit/Tokenizer/JaTinySegmenterTokenizerTest.php (1 issue)

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
namespace Onoi\Tesa\Tests;
4
5
use Onoi\Tesa\Tokenizer\JaTinySegmenterTokenizer;
6
7
/**
8
 * @covers \Onoi\Tesa\Tokenizer\JaTinySegmenterTokenizer
9
 * @group onoi-tesa
10
 *
11
 * @license GNU GPL v2+
12
 * @since 0.1
13
 *
14
 * @author mwjames
15
 */
16
class JaTinySegmenterTokenizerTest extends \PHPUnit_Framework_TestCase {
17
18
	public function testCanConstruct() {
19
20
		$tokenizer = $this->getMockBuilder( '\Onoi\Tesa\Tokenizer\Tokenizer' )
21
			->disableOriginalConstructor()
22
			->getMockForAbstractClass();
23
24
		$this->assertInstanceOf(
25
			'\Onoi\Tesa\Tokenizer\JaTinySegmenterTokenizer',
26
			new JaTinySegmenterTokenizer( $tokenizer )
27
		);
28
	}
29
30
	/**
31
	 * @dataProvider stringProvider
32
	 */
33
	public function testTokenize( $string, $expected ) {
34
35
		$instance = new JaTinySegmenterTokenizer();
36
37
		$this->assertEquals(
38
			$expected,
39
			$instance->tokenize( $string )
40
		);
41
	}
42
43
	public function stringProvider() {
44
45
		$provider[] = array(
0 ignored issues
show
Coding Style Comprehensibility introduced by
$provider was never initialized. Although not strictly required by PHP, it is generally a good practice to add $provider = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
46
			'極めてコンパクトな日本語分かち書きソフトウェアです。',
47
			array(
48
				'極め', // should be 極めて
49
				'て',
50
				'コンパクト',
51
				'な',
52
				'日本',
53
				'語分',
54
				'かち',
55
				'書き',
56
				'ソフトウェア',
57
				'です',
58
				'。'
59
			)
60
		);
61
62
		$provider[] = array(
63
			'日本語の新聞記事であれば文字単位で95%程度の精度で分かち書きが行えます。 ',
64
			array(
65
				'日本語',
66
				'の',
67
				'新聞',
68
				'記事',
69
				'で',
70
				'あれ',
71
				'ば',
72
				'文字',
73
				'単位',
74
				'で',
75
				'9',
76
				'5',
77
				'%',
78
				'程度',
79
				'の',
80
				'精度',
81
				'で',
82
				'分かち',
83
				'書き',
84
				'が',
85
				'行え',
86
				'ます',
87
				'。'
88
89
			)
90
		);
91
92
		$provider[] = array(
93
			'私の名前は中野です',
94
			array(
95
				'私',
96
				'の',
97
				'名前',
98
				'は',
99
				'中野',
100
				'です'
101
			)
102
		);
103
104
		$provider[] = array(
105
			'TinySegmenterは25kBで書かれています。',
106
			array(
107
				'TinySegmenter',
108
				'は',
109
				'2',
110
				'5',
111
				'kB',
112
				'で',
113
				'書か',
114
				'れ',
115
				'て',
116
				'い',
117
				'ます',
118
				'。'
119
			)
120
		);
121
122
		$provider[] = array(
123
			'隣の客はAK47振りかざしてギャアギャアわめきたてる客だ。',
124
			array(
125
				'隣',
126
				'の',
127
				'客',
128
				'は',
129
				'AK',
130
				'4',
131
				'7',
132
				'振り',
133
				'かざ', // should be かざし
134
				'し',
135
				'て',
136
				'ギャアギャア',
137
				'わめき',
138
				'た',
139
				'てる',
140
				'客',
141
				'だ',
142
				'。'
143
			)
144
		);
145
146
		// See JaCompoundGroupTokenizerTest for comparison
147
		$provider[] = array(
148
			'と歓声を上げていました。 十勝農業改良普及センターによりますと',
149
			array(
150
				'と',
151
				'歓声',
152
				'を',
153
				'上げ',
154
				'て',
155
				'い',
156
				'まし',
157
				'た',
158
				'。',
159
				'十勝農業',
160
				'改良',
161
				'普及',
162
				'センター',
163
				'により',
164
				'ます',
165
				'と'
166
			)
167
		);
168
169
		// See IcuWordBoundaryTokenizerTest
170
		$provider[] = array(
171
			"公明執ようなSNSもストーカー行為の対象に",
172
			array(
173
				'公明執',
174
				'よう',
175
				'な',
176
				'SNS',
177
				'も',
178
				'ストーカー',
179
				'行為',
180
				'の',
181
				'対象',
182
				'に'
183
			)
184
		);
185
186
		// https://github.com/chezou/TinySegmenter.jl/blob/master/test/timemachineu8j.txt
187
188
		return $provider;
189
	}
190
191
}
192