Issues (20)

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.

src/Database/Column.php (1 issue)

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
namespace Taisiya\PropelBundle\Database;
4
5
use Propel\Generator\Model\Behavior;
6
use Taisiya\PropelBundle\Database\Exception\InvalidArgumentException;
7
8
abstract class Column implements ColumnInterface
9
{
10
    const TYPE_BOOLEAN       = 'BOOLEAN';
11
    const TYPE_TINYINT       = 'TINYINT';
12
    const TYPE_SMALLINT      = 'SMALLINT';
13
    const TYPE_INTEGER       = 'INTEGER';
14
    const TYPE_BIGINT        = 'BIGINT';
15
    const TYPE_DOUBLE        = 'DOUBLE';
16
    const TYPE_FLOAT         = 'FLOAT';
17
    const TYPE_REAL          = 'REAL';
18
    const TYPE_DECIMAL       = 'DECIMAL';
19
    const TYPE_NUMERIC       = 'NUMERIC';
20
    const TYPE_CHAR          = 'CHAR';
21
    const TYPE_VARCHAR       = 'VARCHAR';
22
    const TYPE_LONGVARCHAR   = 'LONGVARCHAR';
23
    const TYPE_DATE          = 'DATE';
24
    const TYPE_TIME          = 'TIME';
25
    const TYPE_TIMESTAMP     = 'TIMESTAMP';
26
    const TYPE_BLOB          = 'BLOB';
27
    const TYPE_CLOB          = 'CLOB';
28
    const TYPE_OBJECT        = 'OBJECT';
29
    const TYPE_ARRAY         = 'ARRAY';
30
    const TYPE_ENUM          = 'ENUM';
31
    const TYPE_SET           = 'SET';
32
    const TYPE_GEOMETRY      = 'GEOMETRY';
33
    const TYPE_BU_DATE       = 'BU_DATE';
34
    const TYPE_BU_TIMESTAMP  = 'BU_TIMESTAMP';
35
    const TYPE_BOOLEAN_EMU   = 'BOOLEAN_EMU';
36
    const TYPE_BINARY        = 'BINARY';
37
    const TYPE_VARBINARY     = 'VARBINARY';
38
    const TYPE_LONGVARBINARY = 'LONGVARBINARY';
39
40
    const SQL_TYPE_BOOLEAN = 'boolean';
41
    const SQL_TYPE_INT     = 'int';
42
    const SQL_TYPE_INTEGER = 'integer';
43
    const SQL_TYPE_DOUBLE  = 'double';
44
    const SQL_TYPE_FLOAT   = 'float';
45
    const SQL_TYPE_STRING  = 'string';
46
47
    /**
48
     * @var array
49
     */
50
    private $foreignKeys = [];
51
52
    /**
53
     * Object model class name. By default,
54
     * Propel uses a CamelCase version of the table name as phpName.
55
     *
56
     * @var string|null
57
     */
58
    private $phpName = null;
59
60
    /**
61
     * The table map name.
62
     *
63
     * @var string|null
64
     */
65
    private $tableMapName = null;
66
67
    /**
68
     * Is primary key or not.
69
     *
70
     * @var bool
71
     */
72
    private $primaryKey = false;
73
74
    /**
75
     * Is required or not.
76
     *
77
     * @var bool
78
     */
79
    private $required = false;
80
81
    /**
82
     * The database-agnostic column type.
83
     * Propel maps native SQL types to these types depending on the RDBMS.
84
     * Using Propel types guarantees that a column definition is portable.
85
     *
86
     * @var string|null
87
     */
88
    private $type = null;
89
90
    /**
91
     * The PHP type.
92
     *
93
     * @var string|null
94
     */
95
    private $phpType = null;
96
97
    /**
98
     * The SQL type to be used in CREATE and ALTER statements
99
     * (overriding the mapping between Propel types and RMDBS type).
100
     *
101
     * @var string|null
102
     */
103
    private $sqlType = null;
104
105
    /**
106
     * Numeric length of column.
107
     *
108
     * @var int|null
109
     */
110
    private $size = null;
111
112
    /**
113
     * Digits after decimal place.
114
     *
115
     * @var int|null
116
     */
117
    private $scale = null;
118
119
    /**
120
     * The default value that the object will have for this column in the PHP instance
121
     * after creating a “new Object”. This value is always interpreted as a string.
122
     *
123
     * @var string|null
124
     */
125
    private $defaultvalue = null;
126
127
    /**
128
     * The default value for this column as expressed in SQL. This value is used solely
129
     * for the “sql” target which builds your database from the schema.xml file.
130
     * The defaultExpr is the SQL expression used as the “default” for the column.
131
     *
132
     * @var string|null
133
     */
134
    private $defaultExpr = null;
135
136
    /**
137
     * The list of enumerated values accepted on an ENUM column.
138
     * The list contains 255 values at most, separated by commas.
139
     *
140
     * @var string|null
141
     */
142
    private $valueSet = null;
143
144
    /**
145
     * @var bool
146
     */
147
    private $autoIncrement = false;
148
149
    /**
150
     * A lazy-loaded column is not fetched from the database by model queries.
151
     * Only the generated getter method for such a column issues a query to the database.
152
     * Useful for large column types (such as CLOB and BLOB).
153
     *
154
     * @var bool
155
     */
156
    private $lazyLoad = false;
157
158
    /**
159
     * Column description.
160
     *
161
     * @var string|null
162
     */
163
    private $description = null;
164
165
    /**
166
     * A column defined as primary string serves as default value for a __toString() method
167
     * in the generated Propel object.
168
     *
169
     * @var bool
170
     */
171
    private $primaryString = false;
172
173
    /**
174
     * @var string
175
     */
176
    private $phpNamingMethod = Database::PHP_NAMING_METHOD_UNDERSCORE;
177
178
    /**
179
     * @var string|bool
180
     */
181
    private $inheritance = false;
182
183
    /**
184
     * @param ForeignKey $foreignKey
185
     *
186
     * @throws InvalidArgumentException
187
     *
188
     * @return Column
189
     */
190
    final public function addForeignKey(ForeignKey $foreignKey): Column
191
    {
192
        if (array_key_exists($foreignKey->getName(), $this->foreignKeys)) {
193
            throw new InvalidArgumentException('Foreign key '.$foreignKey->getName().' already added.');
194
        }
195
196
        $this->foreignKeys[$foreignKey->getName()] = $foreignKey;
197
198
        return $this;
199
    }
200
201
    /**
202
     * @return array
203
     */
204
    final public function getForeignKeys(): array
205
    {
206
        return $this->foreignKeys;
207
    }
208
209
    /**
210
     * @param string $name
211
     *
212
     * @throws InvalidArgumentException
213
     *
214
     * @return ForeignKey
215
     */
216
    final public function getForeignKey(string $name): ForeignKey
217
    {
218
        if (!$this->hasForeignKey($name)) {
219
            throw new InvalidArgumentException('Foreign key '.$name.' not added.');
220
        }
221
222
        return $this->foreignKeys[$name];
223
    }
224
225
    /**
226
     * @param string $name
227
     *
228
     * @return bool
229
     */
230
    final public function hasForeignKey(string $name): bool
231
    {
232
        return array_key_exists($name, $this->foreignKeys);
233
    }
234
235
    /**
236
     * @return null|string
237
     */
238
    final public function getPhpName(): ? string
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected '?'
Loading history...
239
    {
240
        return $this->phpName;
241
    }
242
243
    /**
244
     * @param null|string $phpName
245
     *
246
     * @return ColumnInterface
247
     */
248
    final public function setPhpName(string $phpName = null) : ColumnInterface
249
    {
250
        $this->phpName = $phpName;
251
252
        return $this;
253
    }
254
255
    /**
256
     * @return null|string
257
     */
258
    final public function getTableMapName(): ? string
259
    {
260
        return $this->tableMapName;
261
    }
262
263
    /**
264
     * @param null|string $tableMapName
265
     *
266
     * @return ColumnInterface
267
     */
268
    final public function setTableMapName(string $tableMapName = null) : ColumnInterface
269
    {
270
        $this->tableMapName = $tableMapName;
271
272
        return $this;
273
    }
274
275
    /**
276
     * @return bool
277
     */
278
    final public function isPrimaryKey(): bool
279
    {
280
        return $this->primaryKey;
281
    }
282
283
    /**
284
     * @param bool $primaryKey
285
     *
286
     * @return ColumnInterface
287
     */
288
    final public function setPrimaryKey(bool $primaryKey): ColumnInterface
289
    {
290
        $this->primaryKey = $primaryKey;
291
292
        return $this;
293
    }
294
295
    /**
296
     * @return bool
297
     */
298
    final public function isRequired(): bool
299
    {
300
        return $this->required;
301
    }
302
303
    /**
304
     * @param bool $required
305
     *
306
     * @return ColumnInterface
307
     */
308
    final public function setRequired(bool $required): ColumnInterface
309
    {
310
        $this->required = $required;
311
312
        return $this;
313
    }
314
315
    /**
316
     * @return null|string
317
     */
318
    final public function getType(): ? string
319
    {
320
        return $this->type;
321
    }
322
323
    /**
324
     * @param null|string $type
325
     *
326
     * @throws \InvalidArgumentException
327
     *
328
     * @return ColumnInterface
329
     */
330
    final public function setType(string $type = null) : ColumnInterface
331
    {
332
        if ($type) {
333
            $available = [
334
                self::TYPE_ARRAY,
335
                self::TYPE_BIGINT,
336
                self::TYPE_BINARY,
337
                self::TYPE_BLOB,
338
                self::TYPE_BOOLEAN,
339
                self::TYPE_BOOLEAN_EMU,
340
                self::TYPE_BU_DATE,
341
                self::TYPE_BU_TIMESTAMP,
342
                self::TYPE_CHAR,
343
                self::TYPE_CLOB,
344
                self::TYPE_BINARY,
345
                self::TYPE_BLOB,
346
                self::TYPE_DATE,
347
                self::TYPE_DECIMAL,
348
                self::TYPE_DOUBLE,
349
                self::TYPE_ENUM,
350
                self::TYPE_FLOAT,
351
                self::TYPE_GEOMETRY,
352
                self::TYPE_INTEGER,
353
                self::TYPE_LONGVARBINARY,
354
                self::TYPE_NUMERIC,
355
                self::TYPE_OBJECT,
356
                self::TYPE_REAL,
357
                self::TYPE_SET,
358
                self::TYPE_SMALLINT,
359
                self::TYPE_TIME,
360
                self::TYPE_TIMESTAMP,
361
                self::TYPE_TINYINT,
362
                self::TYPE_VARCHAR,
363
                self::TYPE_VARBINARY,
364
            ];
365
366
            if (!in_array($type, $available)) {
367
                throw new \InvalidArgumentException('Invalid Propel type.');
368
            }
369
        }
370
371
        $this->type = $type;
372
373
        return $this;
374
    }
375
376
    /**
377
     * @return null|string
378
     */
379
    final public function getPhpType(): ? string
380
    {
381
        return $this->phpType;
382
    }
383
384
    /**
385
     * @param null|string $phpType
386
     *
387
     * @return ColumnInterface
388
     */
389
    final public function setPhpType(string $phpType = null) : ColumnInterface
390
    {
391
        $this->phpType = $phpType;
392
393
        return $this;
394
    }
395
396
    /**
397
     * @return null|string
398
     */
399
    final public function getSqlType(): ? string
400
    {
401
        return $this->sqlType;
402
    }
403
404
    /**
405
     * @param null|string $sqlType
406
     *
407
     * @throws \InvalidArgumentException
408
     *
409
     * @return ColumnInterface
410
     */
411
    final public function setSqlType(string $sqlType = null) : ColumnInterface
412
    {
413
        if ($sqlType) {
414
            $available = [
415
                self::SQL_TYPE_BOOLEAN,
416
                self::SQL_TYPE_DOUBLE,
417
                self::SQL_TYPE_FLOAT,
418
                self::SQL_TYPE_INT,
419
                self::SQL_TYPE_INTEGER,
420
                self::SQL_TYPE_STRING,
421
            ];
422
423
            if (!in_array($sqlType, $available)) {
424
                if (!class_exists($sqlType)) {
425
                    throw new \InvalidArgumentException('Invalid SQL type: '.$sqlType);
426
                } else {
427
                    $reflection = new \ReflectionClass($sqlType);
428
                    if (!$reflection->isSubclassOf(Behavior::class)) {
429
                        throw new \InvalidArgumentException('SQL type '.$sqlType.' must be instance of '.Behavior::class);
430
                    }
431
                }
432
            }
433
        }
434
435
        $this->sqlType = $sqlType;
436
437
        return $this;
438
    }
439
440
    /**
441
     * @return int|null
442
     */
443
    final public function getSize(): ? int
444
    {
445
        return $this->size;
446
    }
447
448
    /**
449
     * @param int|null $size
450
     *
451
     * @return ColumnInterface
452
     */
453
    final public function setSize(int $size = null) : ColumnInterface
454
    {
455
        $this->size = $size;
456
457
        return $this;
458
    }
459
460
    /**
461
     * @return int|null
462
     */
463
    final public function getScale(): ? int
464
    {
465
        return $this->scale;
466
    }
467
468
    /**
469
     * @param int|null $scale
470
     *
471
     * @return ColumnInterface
472
     */
473
    final public function setScale(int $scale = null) : ColumnInterface
474
    {
475
        $this->scale = $scale;
476
477
        return $this;
478
    }
479
480
    /**
481
     * @return null|string
482
     */
483
    final public function getDefaultvalue(): ? string
484
    {
485
        return $this->defaultvalue;
486
    }
487
488
    /**
489
     * @param null|string $defaultvalue
490
     *
491
     * @return ColumnInterface
492
     */
493
    final public function setDefaultvalue(string $defaultvalue = null) : ColumnInterface
494
    {
495
        $this->defaultvalue = $defaultvalue;
496
497
        return $this;
498
    }
499
500
    /**
501
     * @return null|string
502
     */
503
    final public function getDefaultExpr(): ? string
504
    {
505
        return $this->defaultExpr;
506
    }
507
508
    /**
509
     * @param null|string $defaultExpr
510
     *
511
     * @return ColumnInterface
512
     */
513
    final public function setDefaultExpr(string $defaultExpr = null) : ColumnInterface
514
    {
515
        $this->defaultExpr = $defaultExpr;
516
517
        return $this;
518
    }
519
520
    /**
521
     * @return null|string
522
     */
523
    final public function getValueSet(): ? string
524
    {
525
        return $this->valueSet;
526
    }
527
528
    /**
529
     * @param null|string $valueSet
530
     *
531
     * @return ColumnInterface
532
     */
533
    final public function setValueSet(string $valueSet = null) : ColumnInterface
534
    {
535
        $this->valueSet = $valueSet;
536
537
        return $this;
538
    }
539
540
    /**
541
     * @return bool
542
     */
543
    final public function isAutoIncrement(): bool
544
    {
545
        return $this->autoIncrement;
546
    }
547
548
    /**
549
     * @param bool $autoIncrement
550
     *
551
     * @return ColumnInterface
552
     */
553
    final public function setAutoIncrement(bool $autoIncrement): ColumnInterface
554
    {
555
        $this->autoIncrement = $autoIncrement;
556
557
        return $this;
558
    }
559
560
    /**
561
     * @return bool
562
     */
563
    final public function isLazyLoad(): bool
564
    {
565
        return $this->lazyLoad;
566
    }
567
568
    /**
569
     * @param bool $lazyLoad
570
     *
571
     * @return ColumnInterface
572
     */
573
    final public function setLazyLoad(bool $lazyLoad): ColumnInterface
574
    {
575
        $this->lazyLoad = $lazyLoad;
576
577
        return $this;
578
    }
579
580
    /**
581
     * @return null|string
582
     */
583
    final public function getDescription(): ? string
584
    {
585
        return $this->description;
586
    }
587
588
    /**
589
     * @param null|string $description
590
     *
591
     * @return ColumnInterface
592
     */
593
    final public function setDescription(string $description = null) : ColumnInterface
594
    {
595
        $this->description = $description;
596
597
        return $this;
598
    }
599
600
    /**
601
     * @return bool
602
     */
603
    final public function isPrimaryString(): bool
604
    {
605
        return $this->primaryString;
606
    }
607
608
    /**
609
     * @param bool $primaryString
610
     *
611
     * @return ColumnInterface
612
     */
613
    final public function setPrimaryString(bool $primaryString): ColumnInterface
614
    {
615
        $this->primaryString = $primaryString;
616
617
        return $this;
618
    }
619
620
    /**
621
     * @return string
622
     */
623
    final public function getPhpNamingMethod(): string
624
    {
625
        return $this->phpNamingMethod;
626
    }
627
628
    /**
629
     * @param string $phpNamingMethod
630
     *
631
     * @return ColumnInterface
632
     */
633
    final public function setPhpNamingMethod(string $phpNamingMethod): ColumnInterface
634
    {
635
        $this->phpNamingMethod = $phpNamingMethod;
636
637
        return $this;
638
    }
639
640
    /**
641
     * @return bool|string
642
     */
643
    final public function getInheritance(): ? string
644
    {
645
        return $this->inheritance;
646
    }
647
648
    /**
649
     * @param bool|string $inheritance
650
     *
651
     * @return ColumnInterface
652
     */
653
    final public function setInheritance(string $inheritance = null) : ColumnInterface
654
    {
655
        $this->inheritance = $inheritance;
656
657
        return $this;
658
    }
659
660
    /**
661
     * @param \DOMDocument $dom
662
     * @param \DOMElement  $table
663
     */
664
    final public function appendToXmlDocument(\DOMDocument $dom, \DOMElement $table): void
665
    {
666
        $column = $dom->createElement('column');
667
        $column->setAttribute('name', $this::getName());
668
669
        $additionalProperties = [
670
            'phpName',
671
            'tableMapName',
672
            'primaryKey',
673
            'required',
674
            'type',
675
            'phpType',
676
            'sqlType',
677
            'size',
678
            'scale',
679
            'defaultValue',
680
            'defaultExpr',
681
            'valueSet',
682
            'autoIncrement',
683
            'lazyLoad',
684
            'description',
685
            'primaryString',
686
            'phpNamingMethod',
687
            'inheritance',
688
        ];
689
690
        foreach ($additionalProperties as $propertyName) {
691
            $method = method_exists($this, 'get'.ucfirst($propertyName))
692
                ? 'get'.ucfirst($propertyName)
693
                : 'is'.ucfirst($propertyName);
694
695
            $propertyValue = $this->{$method}();
696
            if ($propertyValue != '') {
697
                if (is_bool($propertyValue)) {
698
                    $propertyValue = $propertyValue ? 'true' : false;
699
                }
700
                $column->setAttribute($propertyName, $propertyValue);
701
            }
702
        }
703
704
        $table->appendChild($column);
705
    }
706
}
707