Skip to content

Commit

Permalink
Make the primary key not accessible.
Browse files Browse the repository at this point in the history
Letting the primary key be set through mass assignment can allow some
interesting problems when application logic forgets to handle ACLs
properly.
  • Loading branch information
markstory committed Mar 18, 2014
1 parent 6dfeeb6 commit 141e293
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Console/Command/Task/ModelTask.php
Expand Up @@ -363,8 +363,9 @@ public function getFields($model) {
}
$schema = $model->schema();
$columns = $schema->columns();
$exclude = ['created', 'modified', 'updated'];
return array_diff($columns, $exclude);
$primary = $this->getPrimaryKey($model);
$exclude = array_merge($primary, ['created', 'modified', 'updated']);
return array_values(array_diff($columns, $exclude));
}

/**
Expand Down
1 change: 0 additions & 1 deletion tests/TestCase/Console/Command/Task/ModelTaskTest.php
Expand Up @@ -295,7 +295,6 @@ public function testGetFields() {
$model = TableRegistry::get('BakeArticles');
$result = $this->Task->getFields($model);
$expected = [
'id',
'bake_user_id',
'title',
'body',
Expand Down

0 comments on commit 141e293

Please sign in to comment.