2016-04-17 23:13:39 +02:00
|
|
|
<?php
|
|
|
|
App::uses('Component', 'Controller');
|
|
|
|
|
2018-07-19 11:48:22 +02:00
|
|
|
class ACLComponent extends Component
|
|
|
|
{
|
2016-04-17 23:13:39 +02:00
|
|
|
|
2018-07-19 11:48:22 +02:00
|
|
|
// syntax:
|
|
|
|
// $__aclList[$controller][$action] = $permission_rules
|
|
|
|
// $controller == '*' - any controller can have this action
|
|
|
|
// $action == array() - site admin only has access
|
|
|
|
// $action == '*' - any role has access
|
|
|
|
// $action == array('OR' => array()) - any role in the array has access
|
|
|
|
// $action == array('AND' => array()) - roles with all permissions in the array have access
|
|
|
|
// If we add any new functionality to MISP and we don't add it to this list, it will only be visible to site admins.
|
|
|
|
private $__aclList = array(
|
|
|
|
'*' => array(
|
|
|
|
'blackhole' => array(),
|
|
|
|
'checkAuthUser' => array(),
|
|
|
|
'checkExternalAuthUser' => array(),
|
|
|
|
'cleanModelCaches' => array(),
|
|
|
|
'debugACL' => array(),
|
|
|
|
'generateCount' => array(),
|
|
|
|
'pruneDuplicateUUIDs' => array(),
|
|
|
|
'queryACL' => array(),
|
|
|
|
'removeDuplicateEvents' => array(),
|
2019-11-29 10:55:31 +01:00
|
|
|
'restSearch' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'updateDatabase' => array(),
|
|
|
|
'upgrade2324' => array(),
|
|
|
|
),
|
|
|
|
'attributes' => array(
|
|
|
|
'add' => array('perm_add'),
|
|
|
|
'add_attachment' => array('perm_add'),
|
|
|
|
'add_threatconnect' => array('perm_add'),
|
|
|
|
'addTag' => array('perm_tagger'),
|
|
|
|
'attributeReplace' => array('perm_add'),
|
|
|
|
'attributeStatistics' => array('*'),
|
|
|
|
'bro' => array('*'),
|
|
|
|
'checkAttachments' => array(),
|
|
|
|
'checkComposites' => array('perm_admin'),
|
|
|
|
'checkOrphanedAttributes' => array(),
|
|
|
|
'delete' => array('perm_add'),
|
|
|
|
'deleteSelected' => array('perm_add'),
|
|
|
|
'describeTypes' => array('*'),
|
|
|
|
'download' => array('*'),
|
|
|
|
'downloadAttachment' => array('*'),
|
|
|
|
'downloadSample' => array('*'),
|
|
|
|
'edit' => array('perm_add'),
|
|
|
|
'editField' => array('perm_add'),
|
|
|
|
'editSelected' => array('perm_add'),
|
2018-11-23 14:11:33 +01:00
|
|
|
'exportSearch' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'fetchEditForm' => array('perm_add'),
|
|
|
|
'fetchViewValue' => array('*'),
|
|
|
|
'generateCorrelation' => array(),
|
2020-07-31 10:23:14 +02:00
|
|
|
'getMassEditForm' => array('perm_add'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'hoverEnrichment' => array('perm_add'),
|
|
|
|
'index' => array('*'),
|
|
|
|
'pruneOrphanedAttributes' => array(),
|
|
|
|
'removeTag' => array('perm_tagger'),
|
|
|
|
'reportValidationIssuesAttributes' => array(),
|
|
|
|
'restore' => array('perm_add'),
|
|
|
|
'restSearch' => array('*'),
|
|
|
|
'returnAttributes' => array('*'),
|
|
|
|
'rpz' => array('*'),
|
|
|
|
'search' => array('*'),
|
|
|
|
'searchAlternate' => array('*'),
|
|
|
|
'toggleCorrelation' => array('perm_add'),
|
|
|
|
'text' => array('*'),
|
2019-02-27 20:29:56 +01:00
|
|
|
'toggleToIDS' => array('perm_add'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'updateAttributeValues' => array('perm_add'),
|
|
|
|
'view' => array('*'),
|
2019-03-15 15:19:39 +01:00
|
|
|
'viewPicture' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
),
|
2020-11-11 10:46:38 +01:00
|
|
|
'authKeys' => [
|
|
|
|
'add' => ['perm_auth'],
|
|
|
|
'delete' => ['perm_auth'],
|
|
|
|
'edit' => ['perm_auth'],
|
|
|
|
'index' => ['perm_auth'],
|
|
|
|
'view' => ['perm_auth']
|
|
|
|
],
|
2020-11-30 23:48:20 +01:00
|
|
|
'cerebrates' => [
|
|
|
|
'add' => [],
|
|
|
|
'delete' => [],
|
|
|
|
'download_org' => [],
|
|
|
|
'edit' => [],
|
|
|
|
'index' => [],
|
|
|
|
'preview_orgs' => [],
|
|
|
|
'pull_orgs' => [],
|
|
|
|
'view' => []
|
|
|
|
],
|
2021-01-07 09:31:38 +01:00
|
|
|
'correlationExclusions' => [
|
|
|
|
'add' => [],
|
|
|
|
'clean' => [],
|
|
|
|
'delete' => [],
|
|
|
|
'index' => [],
|
|
|
|
'view' => []
|
|
|
|
],
|
2020-03-01 18:05:21 +01:00
|
|
|
'dashboards' => array(
|
|
|
|
'getForm' => array('*'),
|
|
|
|
'index' => array('*'),
|
|
|
|
'updateSettings' => array('*'),
|
|
|
|
'getEmptyWidget' => array('*'),
|
2020-03-08 23:36:27 +01:00
|
|
|
'renderWidget' => array('*'),
|
|
|
|
'listTemplates' => array('*'),
|
|
|
|
'saveTemplate' => array('*'),
|
|
|
|
'export' => array('*'),
|
2020-03-10 15:11:13 +01:00
|
|
|
'import' => array('*'),
|
|
|
|
'deleteTemplate' => array('*')
|
2020-03-01 18:05:21 +01:00
|
|
|
),
|
2019-08-19 15:19:01 +02:00
|
|
|
'decayingModel' => array(
|
|
|
|
"update" => array(),
|
|
|
|
"export" => array('*'),
|
|
|
|
"import" => array('*'),
|
|
|
|
"view" => array('*'),
|
|
|
|
"index" => array('*'),
|
2019-08-29 16:01:55 +02:00
|
|
|
"add" => array( 'OR' => array('perm_admin', 'perm_decaying')),
|
|
|
|
"edit" => array( 'OR' => array('perm_admin', 'perm_decaying')),
|
|
|
|
"delete" => array( 'OR' => array('perm_admin', 'perm_decaying')),
|
|
|
|
"enable" => array( 'OR' => array('perm_admin', 'perm_decaying')),
|
|
|
|
"disable" => array( 'OR' => array('perm_admin', 'perm_decaying')),
|
|
|
|
"decayingTool" => array( 'OR' => array('perm_admin', 'perm_decaying')),
|
2019-08-19 15:19:01 +02:00
|
|
|
"getAllDecayingModels" => array('*'),
|
|
|
|
"decayingToolBasescore" => array('*'),
|
|
|
|
"decayingToolSimulation" => array('*'),
|
|
|
|
"decayingToolRestSearch" => array('*'),
|
|
|
|
"decayingToolComputeSimulation" => array('*')
|
|
|
|
),
|
|
|
|
'decayingModelMapping' => array(
|
|
|
|
"viewAssociatedTypes" => array('*'),
|
2019-08-29 16:01:55 +02:00
|
|
|
"linkAttributeTypeToModel" => array( 'OR' => array('perm_admin', 'perm_decaying'))
|
2019-08-19 15:19:01 +02:00
|
|
|
),
|
2019-08-29 09:27:19 +02:00
|
|
|
'communities' => array(
|
|
|
|
'index' => array(),
|
|
|
|
'requestAccess' => array(),
|
|
|
|
'view' => array()
|
|
|
|
),
|
2020-09-01 12:56:35 +02:00
|
|
|
'eventBlocklists' => array(
|
2020-08-21 13:41:48 +02:00
|
|
|
'add' => [
|
|
|
|
'AND' => [
|
|
|
|
'host_org_user',
|
|
|
|
'perm_add'
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'delete' => [
|
|
|
|
'AND' => [
|
|
|
|
'host_org_user',
|
|
|
|
'perm_add'
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'edit' => [
|
|
|
|
'AND' => [
|
|
|
|
'host_org_user',
|
|
|
|
'perm_add'
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'index' => [
|
|
|
|
'AND' => [
|
|
|
|
'host_org_user',
|
|
|
|
'perm_add'
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'massDelete' => [
|
|
|
|
'AND' => [
|
|
|
|
'host_org_user',
|
|
|
|
'perm_add'
|
|
|
|
]
|
|
|
|
]
|
2018-07-19 11:48:22 +02:00
|
|
|
),
|
|
|
|
'eventDelegations' => array(
|
2020-12-09 17:29:08 +01:00
|
|
|
'acceptDelegation' => array('AND' => ['delegation_enabled', 'perm_add']),
|
|
|
|
'delegateEvent' => array('AND' => ['delegation_enabled', 'perm_delegate']),
|
|
|
|
'deleteDelegation' => array('AND' => ['delegation_enabled', 'perm_add']),
|
|
|
|
'index' => array('delegation_enabled'),
|
|
|
|
'view' => array('delegation_enabled'),
|
2018-07-19 11:48:22 +02:00
|
|
|
),
|
2020-09-17 15:06:55 +02:00
|
|
|
'eventReports' => array(
|
|
|
|
'add' => array('perm_add'),
|
|
|
|
'view' => array('*'),
|
|
|
|
'viewSummary' => array('*'),
|
|
|
|
'edit' => array('perm_add'),
|
|
|
|
'delete' => array('perm_add'),
|
2020-11-16 10:48:36 +01:00
|
|
|
'reportFromEvent' => array('perm_add'),
|
2020-09-17 15:06:55 +02:00
|
|
|
'restore' => array('perm_add'),
|
2020-10-09 17:11:31 +02:00
|
|
|
'index' => array('*'),
|
|
|
|
'getProxyMISPElements' => array('*'),
|
2020-10-30 08:04:33 +01:00
|
|
|
'extractAllFromReport' => array('*'),
|
|
|
|
'extractFromReport' => array('*'),
|
|
|
|
'replaceSuggestionInReport' => array('*'),
|
|
|
|
'importReportFromUrl' => array('*'),
|
2020-09-17 15:06:55 +02:00
|
|
|
),
|
2018-07-19 11:48:22 +02:00
|
|
|
'events' => array(
|
|
|
|
'add' => array('perm_add'),
|
|
|
|
'addIOC' => array('perm_add'),
|
|
|
|
'addTag' => array('perm_tagger'),
|
|
|
|
'add_misp_export' => array('perm_modify'),
|
|
|
|
'alert' => array('perm_publish'),
|
|
|
|
'automation' => array('perm_auth'),
|
|
|
|
'checkLocks' => array('perm_add'),
|
|
|
|
'checkPublishedStatus' => array('*'),
|
|
|
|
'checkuuid' => array('perm_sync'),
|
|
|
|
'contact' => array('*'),
|
|
|
|
'csv' => array('*'),
|
2019-06-04 19:45:28 +02:00
|
|
|
'cullEmptyEvents' => array(),
|
2018-07-19 11:48:22 +02:00
|
|
|
'delegation_index' => array('*'),
|
|
|
|
'delete' => array('perm_add'),
|
|
|
|
'deleteNode' => array('*'),
|
|
|
|
'dot' => array(),
|
|
|
|
'downloadExport' => array('*'),
|
|
|
|
'downloadOpenIOCEvent' => array('*'),
|
|
|
|
'edit' => array('perm_add'),
|
|
|
|
'enrichEvent' => array('perm_add'),
|
|
|
|
'export' => array('*'),
|
|
|
|
'exportChoice' => array('*'),
|
2019-02-10 13:08:12 +01:00
|
|
|
'exportModule' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'filterEventIdsForPush' => array('perm_sync'),
|
|
|
|
'filterEventIndex' => array('*'),
|
|
|
|
'freeTextImport' => array('perm_add'),
|
|
|
|
'getEditStrategy' => array('perm_add'),
|
|
|
|
'getEventInfoById' => array('*'),
|
|
|
|
'getEventGraphReferences' => array('*'),
|
|
|
|
'getEventGraphTags' => array('*'),
|
|
|
|
'getEventGraphGeneric' => array('*'),
|
2019-06-13 09:16:34 +02:00
|
|
|
'getEventTimeline' => array('*'),
|
2019-03-15 15:32:18 +01:00
|
|
|
'genDistributionGraph' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'getDistributionGraph' => array('*'),
|
|
|
|
'getReferenceData' => array('*'),
|
|
|
|
'getReferences' => array('*'),
|
|
|
|
'getObjectTemplate' => array('*'),
|
2019-03-25 15:53:15 +01:00
|
|
|
'handleModuleResults' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'hids' => array('*'),
|
|
|
|
'index' => array('*'),
|
2019-02-10 13:08:12 +01:00
|
|
|
'importChoice' => array('*'),
|
|
|
|
'importModule' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'massDelete' => array('perm_site_admin'),
|
2019-02-10 13:08:12 +01:00
|
|
|
'merge' => array('perm_modify'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'nids' => array('*'),
|
|
|
|
'proposalEventIndex' => array('*'),
|
|
|
|
'publish' => array('perm_publish'),
|
2019-11-25 16:49:07 +01:00
|
|
|
'publishSightings' => array('perm_sighting'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'pushEventToZMQ' => array('perm_publish_zmq'),
|
2019-03-05 12:24:56 +01:00
|
|
|
'pushEventToKafka' => array('perm_publish_kafka'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'pushProposals' => array('perm_sync'),
|
|
|
|
'queryEnrichment' => array('perm_add'),
|
2020-09-16 10:35:54 +02:00
|
|
|
'recoverEvent' => array('perm_site_admin'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'removePivot' => array('*'),
|
|
|
|
'removeTag' => array('perm_tagger'),
|
|
|
|
'reportValidationIssuesEvents' => array(),
|
2020-09-16 10:35:54 +02:00
|
|
|
'restoreDeletedEvents' => array('perm_site_admin'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'restSearch' => array('*'),
|
2020-11-05 16:08:17 +01:00
|
|
|
'runTaxonomyExclusivityCheck' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'saveFreeText' => array('perm_add'),
|
|
|
|
'stix' => array('*'),
|
|
|
|
'stix2' => array('*'),
|
|
|
|
'strposarray' => array(),
|
|
|
|
'toggleCorrelation' => array('perm_add'),
|
2019-01-17 08:27:16 +01:00
|
|
|
'unpublish' => array('perm_modify'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'updateGraph' => array('*'),
|
2019-02-10 13:08:12 +01:00
|
|
|
'upload_analysis_file' => array('perm_add'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'upload_sample' => array('AND' => array('perm_auth', 'perm_add')),
|
|
|
|
'upload_stix' => array('perm_add'),
|
|
|
|
'view' => array('*'),
|
2020-06-09 12:13:22 +02:00
|
|
|
'viewClusterRelations' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'viewEventAttributes' => array('*'),
|
|
|
|
'viewGraph' => array('*'),
|
2019-02-15 09:41:17 +01:00
|
|
|
'viewGalaxyMatrix' => array('*'),
|
2018-11-23 15:52:18 +01:00
|
|
|
'xml' => array('*')
|
2018-07-19 11:48:22 +02:00
|
|
|
),
|
|
|
|
'favouriteTags' => array(
|
|
|
|
'toggle' => array('*'),
|
|
|
|
'getToggleField' => array('*')
|
|
|
|
),
|
|
|
|
'feeds' => array(
|
|
|
|
'add' => array(),
|
|
|
|
'cacheFeeds' => array(),
|
2019-01-20 10:19:05 +01:00
|
|
|
'compareFeeds' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'delete' => array(),
|
|
|
|
'disable' => array(),
|
|
|
|
'edit' => array(),
|
|
|
|
'enable' => array(),
|
2019-03-10 18:09:46 +01:00
|
|
|
'feedCoverage' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'fetchFromAllFeeds' => array(),
|
|
|
|
'fetchFromFeed' => array(),
|
|
|
|
'fetchSelectedFromFreetextIndex' => array(),
|
|
|
|
'getEvent' => array(),
|
|
|
|
'importFeeds' => array(),
|
2020-10-02 17:20:30 +02:00
|
|
|
'index' => ['OR' => [
|
|
|
|
'host_org_user',
|
|
|
|
'perm_site_admin',
|
|
|
|
]],
|
2020-04-17 14:23:54 +02:00
|
|
|
'loadDefaultFeeds' => array('perm_site_admin'),
|
2019-01-20 10:19:05 +01:00
|
|
|
'previewEvent' => array('*'),
|
|
|
|
'previewIndex' => array('*'),
|
2020-10-02 17:20:30 +02:00
|
|
|
'searchCaches' => ['OR' => [
|
|
|
|
'host_org_user',
|
|
|
|
'perm_site_admin',
|
|
|
|
]],
|
2018-07-19 11:48:22 +02:00
|
|
|
'toggleSelected' => array('perm_site_admin'),
|
2019-01-20 10:19:05 +01:00
|
|
|
'view' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
),
|
|
|
|
'galaxies' => array(
|
|
|
|
'attachCluster' => array('perm_tagger'),
|
|
|
|
'attachMultipleClusters' => array('perm_tagger'),
|
2019-03-15 14:33:31 +01:00
|
|
|
'delete' => array(),
|
2020-03-12 10:26:09 +01:00
|
|
|
'export' => array('*'),
|
2020-06-09 12:13:22 +02:00
|
|
|
'forkTree' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'index' => array('*'),
|
2020-03-12 10:26:09 +01:00
|
|
|
'import' => array('perm_galaxy_editor'),
|
2020-06-16 09:18:04 +02:00
|
|
|
'pushCluster' => array('perm_sync'),
|
2020-06-09 12:13:22 +02:00
|
|
|
'relationsGraph' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'selectGalaxy' => array('perm_tagger'),
|
|
|
|
'selectGalaxyNamespace' => array('perm_tagger'),
|
|
|
|
'selectCluster' => array('perm_tagger'),
|
2019-01-06 17:37:13 +01:00
|
|
|
'showGalaxies' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'update' => array(),
|
|
|
|
'view' => array('*'),
|
2020-03-12 10:26:09 +01:00
|
|
|
'viewGraph' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
),
|
2020-07-14 08:24:37 +02:00
|
|
|
'galaxyClusterBlocklists' => array(
|
|
|
|
'add' => array(),
|
|
|
|
'delete' => array(),
|
|
|
|
'edit' => array(),
|
|
|
|
'index' => array(),
|
|
|
|
'massDelete' => array(),
|
|
|
|
),
|
2018-07-19 11:48:22 +02:00
|
|
|
'galaxyClusters' => array(
|
2020-03-12 10:26:09 +01:00
|
|
|
'add' => array('perm_galaxy_editor'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'attachToEvent' => array('perm_tagger'),
|
2020-03-12 10:26:09 +01:00
|
|
|
'delete' => array('perm_galaxy_editor'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'detach' => array('perm_tagger'),
|
2020-03-12 10:26:09 +01:00
|
|
|
'edit' => array('perm_galaxy_editor'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'index' => array('*'),
|
2020-06-16 16:36:49 +02:00
|
|
|
'publish' => array('perm_galaxy_editor'),
|
2020-07-14 08:24:37 +02:00
|
|
|
'restore' => array('perm_galaxy_editor'),
|
2020-06-10 16:00:03 +02:00
|
|
|
'restSearch' => array('*'),
|
2020-06-16 16:36:49 +02:00
|
|
|
'unpublish' => array('perm_galaxy_editor'),
|
2020-06-09 12:13:22 +02:00
|
|
|
'updateCluster' => array('perm_galaxy_editor'),
|
2019-03-20 14:28:08 +01:00
|
|
|
'view' => array('*'),
|
2020-06-09 12:13:22 +02:00
|
|
|
'viewGalaxyMatrix' => array('*'),
|
|
|
|
'viewRelations' => array('*'),
|
|
|
|
'viewRelationTree' => array('*'),
|
|
|
|
),
|
|
|
|
'galaxyClusterRelations' => array(
|
|
|
|
'add' => array('perm_galaxy_editor'),
|
|
|
|
'delete' => array('perm_galaxy_editor'),
|
|
|
|
'edit' => array('perm_galaxy_editor'),
|
|
|
|
'index' => array('*'),
|
2020-06-15 09:01:47 +02:00
|
|
|
'view' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
),
|
|
|
|
'galaxyElements' => array(
|
|
|
|
'index' => array('*')
|
|
|
|
),
|
|
|
|
'jobs' => array(
|
|
|
|
'cache' => array('*'),
|
|
|
|
'getError' => array(),
|
|
|
|
'getGenerateCorrelationProgress' => array('*'),
|
|
|
|
'getProgress' => array('*'),
|
|
|
|
'index' => array(),
|
|
|
|
'clearJobs' => array()
|
|
|
|
),
|
|
|
|
'logs' => array(
|
|
|
|
'admin_index' => array('perm_audit'),
|
|
|
|
'admin_search' => array('perm_audit'),
|
|
|
|
'event_index' => array('*'),
|
|
|
|
'returnDates' => array('*'),
|
|
|
|
'testForStolenAttributes' => array(),
|
|
|
|
'pruneUpdateLogs' => array()
|
|
|
|
),
|
2018-02-16 14:36:57 +01:00
|
|
|
'modules' => array(
|
|
|
|
'index' => array('perm_auth'),
|
|
|
|
'queryEnrichment' => array('perm_auth'),
|
|
|
|
),
|
2018-07-19 11:48:22 +02:00
|
|
|
'news' => array(
|
|
|
|
'add' => array(),
|
|
|
|
'edit' => array(),
|
|
|
|
'delete' => array(),
|
|
|
|
'index' => array('*'),
|
|
|
|
),
|
|
|
|
'noticelists' => array(
|
|
|
|
'delete' => array(),
|
|
|
|
'enableNoticelist' => array(),
|
|
|
|
'getToggleField' => array(),
|
|
|
|
'index' => array('*'),
|
|
|
|
'toggleEnable' => array(),
|
|
|
|
'update' => array(),
|
|
|
|
'view' => array('*')
|
|
|
|
),
|
|
|
|
'objects' => array(
|
2020-05-06 13:25:08 +02:00
|
|
|
'add' => array('perm_add'),
|
|
|
|
'addValueField' => array('perm_add'),
|
|
|
|
'delete' => array('perm_add'),
|
|
|
|
'edit' => array('perm_add'),
|
|
|
|
'get_row' => array('perm_add'),
|
|
|
|
'orphanedObjectDiagnostics' => array(),
|
|
|
|
'editField' => array('perm_add'),
|
|
|
|
'fetchEditForm' => array('perm_add'),
|
|
|
|
'fetchViewValue' => array('*'),
|
|
|
|
'quickAddAttributeForm' => array('perm_add'),
|
|
|
|
'quickFetchTemplateWithValidObjectAttributes' => array('perm_add'),
|
|
|
|
'restSearch' => array('*'),
|
|
|
|
'proposeObjectsFromAttributes' => array('*'),
|
|
|
|
'groupAttributesIntoObject' => array('perm_add'),
|
|
|
|
'revise_object' => array('perm_add'),
|
|
|
|
'view' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
),
|
|
|
|
'objectReferences' => array(
|
|
|
|
'add' => array('perm_add'),
|
|
|
|
'delete' => array('perm_add'),
|
|
|
|
'view' => array('*'),
|
|
|
|
),
|
|
|
|
'objectTemplates' => array(
|
|
|
|
'activate' => array(),
|
|
|
|
'add' => array('perm_object_template'),
|
|
|
|
'edit' => array('perm_object_template'),
|
|
|
|
'delete' => array('perm_object_template'),
|
|
|
|
'getToggleField' => array(),
|
|
|
|
'objectChoice' => array('*'),
|
2019-01-18 16:18:23 +01:00
|
|
|
'objectMetaChoice' => array('perm_add'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'view' => array('*'),
|
|
|
|
'viewElements' => array('*'),
|
|
|
|
'index' => array('*'),
|
|
|
|
'update' => array('perm_site_admin')
|
|
|
|
),
|
|
|
|
'objectTemplateElements' => array(
|
|
|
|
'viewElements' => array('*')
|
|
|
|
),
|
2020-09-01 12:56:35 +02:00
|
|
|
'orgBlocklists' => array(
|
2018-07-19 11:48:22 +02:00
|
|
|
'add' => array(),
|
|
|
|
'delete' => array(),
|
|
|
|
'edit' => array(),
|
|
|
|
'index' => array(),
|
|
|
|
),
|
|
|
|
'organisations' => array(
|
|
|
|
'admin_add' => array(),
|
|
|
|
'admin_delete' => array(),
|
|
|
|
'admin_edit' => array(),
|
|
|
|
'admin_generateuuid' => array(),
|
|
|
|
'admin_merge' => array(),
|
2020-06-30 13:29:48 +02:00
|
|
|
'fetchOrgsForSG' => array('perm_sharing_group'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'fetchSGOrgRow' => array('*'),
|
|
|
|
'getUUIDs' => array('perm_sync'),
|
|
|
|
'index' => array('*'),
|
|
|
|
'view' => array('*'),
|
|
|
|
),
|
|
|
|
'pages' => array(
|
|
|
|
'display' => array('*'),
|
|
|
|
),
|
|
|
|
'posts' => array(
|
|
|
|
'add' => array('*'),
|
|
|
|
'delete' => array('*'),
|
|
|
|
'edit' => array('*'),
|
|
|
|
'pushMessageToZMQ' => array('perm_site_admin')
|
|
|
|
),
|
|
|
|
'regexp' => array(
|
|
|
|
'admin_add' => array('perm_regexp_access'),
|
|
|
|
'admin_clean' => array('perm_regexp_access'),
|
|
|
|
'admin_delete' => array('perm_regexp_access'),
|
|
|
|
'admin_edit' => array('perm_regexp_access'),
|
|
|
|
'admin_index' => array('perm_regexp_access'),
|
|
|
|
'cleanRegexModifiers' => array('perm_regexp_access'),
|
|
|
|
'index' => array('*'),
|
|
|
|
),
|
2019-03-19 11:18:12 +01:00
|
|
|
'restClientHistory' => array(
|
2019-03-19 10:55:27 +01:00
|
|
|
'delete' => array('*'),
|
|
|
|
'index' => array('*')
|
|
|
|
),
|
2018-07-19 11:48:22 +02:00
|
|
|
'roles' => array(
|
|
|
|
'admin_add' => array(),
|
|
|
|
'admin_delete' => array(),
|
|
|
|
'admin_edit' => array(),
|
|
|
|
'admin_set_default' => array(),
|
|
|
|
'index' => array('*'),
|
|
|
|
'view' => array('*'),
|
|
|
|
),
|
|
|
|
'servers' => array(
|
|
|
|
'add' => array(),
|
2019-11-08 13:52:00 +01:00
|
|
|
'dbSchemaDiagnostic' => array(),
|
2019-09-09 13:00:21 +02:00
|
|
|
'cache' => array(),
|
2019-09-13 13:22:23 +02:00
|
|
|
'changePriority' => array(),
|
2018-07-19 11:48:22 +02:00
|
|
|
'checkout' => array(),
|
2019-11-21 10:41:05 +01:00
|
|
|
'clearWorkerQueue' => array(),
|
2019-05-30 14:42:29 +02:00
|
|
|
'createSync' => array('perm_sync'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'delete' => array(),
|
|
|
|
'deleteFile' => array(),
|
|
|
|
'edit' => array(),
|
2020-06-30 13:15:58 +02:00
|
|
|
'eventBlockRule' => array(),
|
2020-06-30 13:29:48 +02:00
|
|
|
'fetchServersForSG' => array('perm_sharing_group'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'filterEventIndex' => array(),
|
2018-11-23 14:11:33 +01:00
|
|
|
'getApiInfo' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'getInstanceUUID' => array('perm_sync'),
|
|
|
|
'getPyMISPVersion' => array('*'),
|
2019-11-13 19:09:37 +01:00
|
|
|
'getRemoteUser' => array(),
|
2019-08-15 20:01:36 +02:00
|
|
|
'getSetting' => array(),
|
2019-09-09 13:00:21 +02:00
|
|
|
'getSubmodulesStatus' => array(),
|
|
|
|
'getSubmoduleQuickUpdateForm' => array(),
|
2019-06-19 14:08:06 +02:00
|
|
|
'getWorkers' => array(),
|
2018-07-19 11:48:22 +02:00
|
|
|
'getVersion' => array('*'),
|
2020-10-02 17:20:30 +02:00
|
|
|
'idTranslator' => ['OR' => [
|
|
|
|
'host_org_user',
|
|
|
|
'perm_site_admin',
|
|
|
|
]],
|
2019-09-09 13:00:21 +02:00
|
|
|
'import' => array(),
|
|
|
|
'index' => array(),
|
2019-04-26 09:45:03 +02:00
|
|
|
'ondemandAction' => array(),
|
2018-07-19 11:48:22 +02:00
|
|
|
'postTest' => array('perm_sync'),
|
|
|
|
'previewEvent' => array(),
|
|
|
|
'previewIndex' => array(),
|
2021-01-18 11:23:26 +01:00
|
|
|
'compareServers' => [],
|
2018-07-19 11:48:22 +02:00
|
|
|
'pull' => array(),
|
|
|
|
'purgeSessions' => array(),
|
|
|
|
'push' => array(),
|
2019-10-15 09:44:20 +02:00
|
|
|
'releaseUpdateLock' => array(),
|
2019-09-10 10:25:14 +02:00
|
|
|
'resetRemoteAuthKey' => array(),
|
2018-08-08 11:29:38 +02:00
|
|
|
'rest' => array('perm_auth'),
|
2020-03-06 15:02:44 +01:00
|
|
|
'restartDeadWorkers' => array(),
|
2018-07-19 11:48:22 +02:00
|
|
|
'restartWorkers' => array(),
|
|
|
|
'serverSettings' => array(),
|
|
|
|
'serverSettingsEdit' => array(),
|
|
|
|
'serverSettingsReloadSetting' => array(),
|
|
|
|
'startWorker' => array(),
|
|
|
|
'startZeroMQServer' => array(),
|
|
|
|
'statusZeroMQServer' => array(),
|
|
|
|
'stopWorker' => array(),
|
|
|
|
'stopZeroMQServer' => array(),
|
2019-09-09 13:00:21 +02:00
|
|
|
'testConnection' => array(),
|
2018-07-19 11:48:22 +02:00
|
|
|
'update' => array(),
|
2019-04-10 10:31:21 +02:00
|
|
|
'updateJSON' => array(),
|
2019-04-26 09:45:03 +02:00
|
|
|
'updateProgress' => array(),
|
2019-04-04 17:35:34 +02:00
|
|
|
'updateSubmodule' => array(),
|
2018-07-19 11:48:22 +02:00
|
|
|
'uploadFile' => array(),
|
2020-09-23 17:28:01 +02:00
|
|
|
'viewDeprecatedFunctionUse' => array(),
|
|
|
|
'killAllWorkers' => ['perm_site_admin'],
|
2018-07-19 11:48:22 +02:00
|
|
|
),
|
|
|
|
'shadowAttributes' => array(
|
|
|
|
'accept' => array('perm_add'),
|
|
|
|
'acceptSelected' => array('perm_add'),
|
|
|
|
'add' => array('perm_add'),
|
|
|
|
'add_attachment' => array('perm_add'),
|
|
|
|
'delete' => array('perm_add'),
|
|
|
|
'discard' => array('perm_add'),
|
|
|
|
'discardSelected' => array('perm_add'),
|
|
|
|
'download' => array('*'),
|
|
|
|
'edit' => array('perm_add'),
|
|
|
|
'generateCorrelation' => array(),
|
|
|
|
'index' => array('*'),
|
|
|
|
'view' => array('*'),
|
|
|
|
),
|
|
|
|
'sharingGroups' => array(
|
|
|
|
'add' => array('perm_sharing_group'),
|
|
|
|
'addServer' => array('perm_sharing_group'),
|
|
|
|
'addOrg' => array('perm_sharing_group'),
|
|
|
|
'delete' => array('perm_sharing_group'),
|
|
|
|
'edit' => array('perm_sharing_group'),
|
|
|
|
'index' => array('*'),
|
|
|
|
'removeServer' => array('perm_sharing_group'),
|
|
|
|
'removeOrg' => array('perm_sharing_group'),
|
|
|
|
'view' => array('*'),
|
|
|
|
),
|
|
|
|
'sightings' => array(
|
|
|
|
'add' => array('perm_sighting'),
|
2018-10-23 13:28:48 +02:00
|
|
|
'restSearch' => array('perm_sighting'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'advanced' => array('perm_sighting'),
|
|
|
|
'delete' => array('perm_sighting'),
|
|
|
|
'index' => array('*'),
|
2019-08-20 11:51:11 +02:00
|
|
|
'listSightings' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'quickDelete' => array('perm_sighting'),
|
2019-08-20 11:51:11 +02:00
|
|
|
'viewSightings' => array('*'),
|
2019-11-22 21:53:51 +01:00
|
|
|
'bulkSaveSightings' => array('OR' => array('perm_sync', 'perm_sighting')),
|
2018-10-30 22:00:04 +01:00
|
|
|
'quickAdd' => array('perm_sighting')
|
2018-07-19 11:48:22 +02:00
|
|
|
),
|
2019-11-06 21:20:04 +01:00
|
|
|
'sightingdb' => array(
|
|
|
|
'add' => array(),
|
|
|
|
'edit' => array(),
|
|
|
|
'delete' => array(),
|
|
|
|
'index' => array(),
|
|
|
|
'requestStatus' => array(),
|
|
|
|
'search' => array()
|
|
|
|
),
|
2019-01-01 16:38:57 +01:00
|
|
|
'tagCollections' => array(
|
|
|
|
'add' => array('perm_tag_editor'),
|
|
|
|
'addTag' => array('perm_tag_editor'),
|
|
|
|
'delete' => array('perm_tag_editor'),
|
|
|
|
'edit' => array('perm_tag_editor'),
|
|
|
|
'getRow' => array('perm_tag_editor'),
|
2019-01-21 15:15:10 +01:00
|
|
|
'import' => array('perm_tag_editor'),
|
2019-01-01 16:38:57 +01:00
|
|
|
'index' => array('*'),
|
|
|
|
'removeTag' => array('perm_tag_editor'),
|
|
|
|
'view' => array('*')
|
|
|
|
),
|
2018-07-19 11:48:22 +02:00
|
|
|
'tags' => array(
|
|
|
|
'add' => array('perm_tag_editor'),
|
|
|
|
'attachTagToObject' => array('perm_tagger'),
|
|
|
|
'delete' => array(),
|
|
|
|
'edit' => array(),
|
|
|
|
'index' => array('*'),
|
|
|
|
'quickAdd' => array('perm_tag_editor'),
|
|
|
|
'removeTagFromObject' => array('perm_tagger'),
|
2019-02-10 21:34:45 +01:00
|
|
|
'search' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'selectTag' => array('perm_tagger'),
|
|
|
|
'selectTaxonomy' => array('perm_tagger'),
|
|
|
|
'showEventTag' => array('*'),
|
|
|
|
'showAttributeTag' => array('*'),
|
2019-01-02 10:06:39 +01:00
|
|
|
'showTagControllerTag' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'tagStatistics' => array('*'),
|
|
|
|
'view' => array('*'),
|
|
|
|
'viewGraph' => array('*'),
|
|
|
|
'viewTag' => array('*')
|
|
|
|
),
|
|
|
|
'tasks' => array(
|
|
|
|
'index' => array(),
|
|
|
|
'setTask' => array(),
|
|
|
|
),
|
|
|
|
'taxonomies' => array(
|
|
|
|
'addTag' => array(),
|
|
|
|
'delete' => array(),
|
|
|
|
'disable' => array(),
|
|
|
|
'disableTag' => array(),
|
|
|
|
'enable' => array(),
|
|
|
|
'index' => array('*'),
|
|
|
|
'taxonomyMassConfirmation' => array('perm_tagger'),
|
2018-09-10 12:53:33 +02:00
|
|
|
'taxonomyMassHide' => array('perm_tagger'),
|
|
|
|
'taxonomyMassUnhide' => array('perm_tagger'),
|
2019-03-19 16:32:20 +01:00
|
|
|
'toggleRequired' => array('perm_site_admin'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'update' => array(),
|
2021-01-12 16:51:05 +01:00
|
|
|
'import' => [],
|
2018-07-19 11:48:22 +02:00
|
|
|
'view' => array('*'),
|
2018-09-10 12:53:33 +02:00
|
|
|
'unhideTag' => array('perm_tagger'),
|
|
|
|
'hideTag' => array('perm_tagger'),
|
2018-07-19 11:48:22 +02:00
|
|
|
),
|
|
|
|
'templateElements' => array(
|
|
|
|
'add' => array('perm_template'),
|
|
|
|
'delete' => array('perm_template'),
|
|
|
|
'edit' => array('perm_template'),
|
|
|
|
'index' => array('*'),
|
|
|
|
'templateElementAddChoices' => array('perm_template'),
|
|
|
|
),
|
|
|
|
'templates' => array(
|
|
|
|
'add' => array('perm_template'),
|
|
|
|
'delete' => array('perm_template'),
|
|
|
|
'deleteTemporaryFile' => array('perm_add'),
|
|
|
|
'edit' => array('perm_template'),
|
|
|
|
'index' => array('*'),
|
|
|
|
'populateEventFromTemplate' => array('perm_add'),
|
|
|
|
'saveElementSorting' => array('perm_template'),
|
|
|
|
'submitEventPopulation' => array('perm_add'),
|
|
|
|
'templateChoices' => array('*'),
|
|
|
|
'uploadFile' => array('*'),
|
|
|
|
'view' => array('*'),
|
|
|
|
),
|
|
|
|
'threads' => array(
|
|
|
|
'index' => array('*'),
|
|
|
|
'view' => array('*'),
|
|
|
|
'viewEvent' => array('*'),
|
|
|
|
),
|
|
|
|
'users' => array(
|
2020-04-07 13:21:01 +02:00
|
|
|
'acceptRegistrations' => array('perm_site_admin'),
|
2020-10-31 15:27:32 +01:00
|
|
|
'admin_add' => ['AND' => ['perm_admin', 'add_user_enabled']],
|
2018-07-19 11:48:22 +02:00
|
|
|
'admin_delete' => array('perm_admin'),
|
|
|
|
'admin_edit' => array('perm_admin'),
|
|
|
|
'admin_email' => array('perm_admin'),
|
|
|
|
'admin_filterUserIndex' => array('perm_admin'),
|
|
|
|
'admin_index' => array('perm_admin'),
|
2020-03-25 11:49:33 +01:00
|
|
|
'admin_monitor' => array('perm_site_admin'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'admin_quickEmail' => array('perm_admin'),
|
|
|
|
'admin_view' => array('perm_admin'),
|
|
|
|
'attributehistogram' => array('*'),
|
2020-10-31 13:57:32 +01:00
|
|
|
'change_pw' => ['AND' => ['self_management_enabled', 'password_change_enabled']],
|
2018-07-19 11:48:22 +02:00
|
|
|
'checkAndCorrectPgps' => array(),
|
|
|
|
'checkIfLoggedIn' => array('*'),
|
|
|
|
'dashboard' => array('*'),
|
|
|
|
'delete' => array('perm_admin'),
|
2020-04-07 13:21:01 +02:00
|
|
|
'discardRegistrations' => array('perm_site_admin'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'downloadTerms' => array('*'),
|
2020-10-31 13:57:32 +01:00
|
|
|
'edit' => array('self_management_enabled'),
|
2020-03-25 15:45:09 +01:00
|
|
|
'email_otp' => array('*'),
|
2019-09-23 20:56:52 +02:00
|
|
|
'searchGpgKey' => array('*'),
|
|
|
|
'fetchGpgKey' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'histogram' => array('*'),
|
2020-10-31 13:57:32 +01:00
|
|
|
'initiatePasswordReset' => ['AND' => ['perm_admin', 'password_change_enabled']],
|
2018-07-19 11:48:22 +02:00
|
|
|
'login' => array('*'),
|
|
|
|
'logout' => array('*'),
|
2020-04-07 13:21:01 +02:00
|
|
|
'register' => array('*'),
|
|
|
|
'registrations' => array('perm_site_admin'),
|
2019-09-09 13:00:21 +02:00
|
|
|
'resetAllSyncAuthKeys' => array(),
|
2018-07-19 11:48:22 +02:00
|
|
|
'resetauthkey' => array('*'),
|
|
|
|
'request_API' => array('*'),
|
|
|
|
'routeafterlogin' => array('*'),
|
|
|
|
'statistics' => array('*'),
|
|
|
|
'tagStatisticsGraph' => array('*'),
|
|
|
|
'terms' => array('*'),
|
|
|
|
'updateLoginTime' => array('*'),
|
2020-11-11 10:46:38 +01:00
|
|
|
'updateToAdvancedAuthKeys' => array(),
|
2018-07-19 11:48:22 +02:00
|
|
|
'verifyCertificate' => array(),
|
|
|
|
'verifyGPG' => array(),
|
|
|
|
'view' => array('*'),
|
2019-09-27 18:48:59 +02:00
|
|
|
'getGpgPublicKey' => array('*'),
|
2018-07-19 11:48:22 +02:00
|
|
|
),
|
2019-09-25 11:50:54 +02:00
|
|
|
'userSettings' => array(
|
|
|
|
'index' => array('*'),
|
|
|
|
'view' => array('*'),
|
|
|
|
'setSetting' => array('*'),
|
|
|
|
'getSetting' => array('*'),
|
2020-03-01 18:05:21 +01:00
|
|
|
'delete' => array('*'),
|
|
|
|
'setHomePage' => array('*')
|
2019-09-25 11:50:54 +02:00
|
|
|
),
|
2018-07-19 11:48:22 +02:00
|
|
|
'warninglists' => array(
|
2018-11-23 14:11:33 +01:00
|
|
|
'checkValue' => array('perm_auth'),
|
2018-07-19 11:48:22 +02:00
|
|
|
'delete' => array(),
|
|
|
|
'enableWarninglist' => array(),
|
|
|
|
'getToggleField' => array(),
|
|
|
|
'index' => array('*'),
|
|
|
|
'toggleEnable' => array(),
|
|
|
|
'update' => array(),
|
|
|
|
'view' => array('*')
|
|
|
|
),
|
2020-09-01 15:59:38 +02:00
|
|
|
'allowedlists' => array(
|
2018-07-19 11:48:22 +02:00
|
|
|
'admin_add' => array('perm_regexp_access'),
|
|
|
|
'admin_delete' => array('perm_regexp_access'),
|
|
|
|
'admin_edit' => array('perm_regexp_access'),
|
|
|
|
'admin_index' => array('perm_regexp_access'),
|
|
|
|
'index' => array('*'),
|
|
|
|
),
|
|
|
|
'eventGraph' => array(
|
|
|
|
'view' => array('*'),
|
|
|
|
'add' => array('perm_add'),
|
|
|
|
'delete' => array('perm_modify'),
|
|
|
|
)
|
|
|
|
);
|
2016-06-04 01:08:16 +02:00
|
|
|
|
2020-10-31 13:57:32 +01:00
|
|
|
private $dynamicChecks = [];
|
2020-11-30 23:48:20 +01:00
|
|
|
|
2020-10-31 10:26:33 +01:00
|
|
|
public function __construct(ComponentCollection $collection, $settings = array())
|
|
|
|
{
|
|
|
|
parent::__construct($collection, $settings);
|
2020-10-31 13:57:32 +01:00
|
|
|
|
|
|
|
$this->dynamicChecks['host_org_user'] = function (array $user) {
|
|
|
|
$hostOrgId = Configure::read('MISP.host_org_id');
|
|
|
|
return (int)$user['org_id'] === (int)$hostOrgId;
|
|
|
|
};
|
|
|
|
$this->dynamicChecks['self_management_enabled'] = function (array $user) {
|
2020-10-31 13:13:53 +01:00
|
|
|
if (Configure::read('MISP.disableUserSelfManagement') && !$user['Role']['perm_admin']) {
|
2020-10-31 10:26:33 +01:00
|
|
|
throw new MethodNotAllowedException('User self-management has been disabled on this instance.');
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
2020-10-31 13:57:32 +01:00
|
|
|
$this->dynamicChecks['password_change_enabled'] = function (array $user) {
|
2020-10-31 10:26:33 +01:00
|
|
|
if (Configure::read('MISP.disable_user_password_change')) {
|
|
|
|
throw new MethodNotAllowedException('User password change has been disabled on this instance.');
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
2020-10-31 15:27:32 +01:00
|
|
|
$this->dynamicChecks['add_user_enabled'] = function (array $user) {
|
|
|
|
if (Configure::read('MISP.disable_user_add')) {
|
|
|
|
throw new MethodNotAllowedException('Adding users has been disabled on this instance.');
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
2020-12-09 17:29:08 +01:00
|
|
|
$this->dynamicChecks['delegation_enabled'] = function (array $user) {
|
|
|
|
return (bool)Configure::read('MISP.delegation');
|
|
|
|
};
|
2020-10-31 10:26:33 +01:00
|
|
|
}
|
2016-06-04 01:08:16 +02:00
|
|
|
|
2019-09-09 13:00:21 +02:00
|
|
|
private function __checkLoggedActions($user, $controller, $action)
|
|
|
|
{
|
|
|
|
$loggedActions = array(
|
|
|
|
'servers' => array(
|
|
|
|
'index' => array(
|
|
|
|
'role' => array(
|
|
|
|
'NOT' => array(
|
|
|
|
'perm_site_admin'
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'message' => __('This could be an indication of an attempted privilege escalation on older vulnerable versions of MISP (<2.4.115)')
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
foreach ($loggedActions as $k => $v) {
|
|
|
|
$loggedActions[$k] = array_change_key_case($v);
|
|
|
|
}
|
|
|
|
if (!empty($loggedActions[$controller])) {
|
|
|
|
if (!empty($loggedActions[$controller][$action])) {
|
|
|
|
$message = $loggedActions[$controller][$action]['message'];
|
|
|
|
$hit = false;
|
|
|
|
if (empty($loggedActions[$controller][$action]['role'])) {
|
|
|
|
$hit = true;
|
|
|
|
} else {
|
|
|
|
$role_req = $loggedActions[$controller][$action]['role'];
|
|
|
|
if (empty($role_req['OR']) && empty($role_req['AND']) && empty($role_req['NOT'])) {
|
|
|
|
$role_req = array('OR' => $role_req);
|
|
|
|
}
|
|
|
|
if (!empty($role_req['NOT'])) {
|
|
|
|
foreach ($role_req['NOT'] as $k => $v) {
|
|
|
|
if (!$user['Role'][$v]) {
|
|
|
|
$hit = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!$hit && !empty($role_req['AND'])) {
|
|
|
|
$subhit = true;
|
|
|
|
foreach ($role_req['AND'] as $k => $v) {
|
|
|
|
$subhit = $subhit && $user['Role'][$v];
|
|
|
|
}
|
|
|
|
if ($subhit) {
|
|
|
|
$hit = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!$hit && !empty($role_req['OR'])) {
|
|
|
|
foreach ($role_req['OR'] as $k => $v) {
|
|
|
|
if ($user['Role'][$v]) {
|
|
|
|
$hit = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($hit) {
|
|
|
|
$this->Log = ClassRegistry::init('Log');
|
|
|
|
$this->Log->create();
|
|
|
|
$this->Log->save(array(
|
|
|
|
'org' => 'SYSTEM',
|
|
|
|
'model' => 'User',
|
|
|
|
'model_id' => $user['id'],
|
|
|
|
'email' => $user['email'],
|
|
|
|
'action' => 'security',
|
|
|
|
'user_id' => $user['id'],
|
|
|
|
'title' => __('User triggered security alert by attempting to access /%s/%s. Reason why this endpoint is of interest: %s', $controller, $action, $message),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-31 10:26:33 +01:00
|
|
|
/**
|
|
|
|
* @param array $user
|
|
|
|
* @param string $controller
|
|
|
|
* @param string $action
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function canUserAccess($user, $controller, $action)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
$this->checkAccess($user, $controller, $action, false);
|
|
|
|
} catch (NotFoundException $e) {
|
|
|
|
throw new RuntimeException("Invalid controller '$controller' specified.", 0, $e);
|
|
|
|
} catch (MethodNotAllowedException $e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-05-24 09:59:46 +02:00
|
|
|
/**
|
|
|
|
* The check works like this:
|
|
|
|
* - If the user is a site admin, return true
|
|
|
|
* - If the requested action has an OR-d list, iterate through the list. If any of the permissions are set for the user, return true
|
|
|
|
* - If the requested action has an AND-ed list, iterate through the list. If any of the permissions for the user are not set, turn the check to false. Otherwise return true.
|
|
|
|
* - If the requested action has a permission, check if the user's role has it flagged. If yes, return true
|
|
|
|
* - If we fall through all of the checks, return an exception.
|
|
|
|
*
|
|
|
|
* @param array|null $user
|
|
|
|
* @param string $controller
|
|
|
|
* @param string $action
|
2020-10-31 10:26:33 +01:00
|
|
|
* @param bool $checkLoggedActions
|
|
|
|
* @return true
|
2020-05-24 09:59:46 +02:00
|
|
|
* @throws NotFoundException
|
|
|
|
* @throws MethodNotAllowedException
|
|
|
|
* @throws InternalErrorException
|
|
|
|
*/
|
2020-10-31 10:26:33 +01:00
|
|
|
public function checkAccess($user, $controller, $action, $checkLoggedActions = true)
|
2018-07-19 11:48:22 +02:00
|
|
|
{
|
|
|
|
$controller = lcfirst(Inflector::camelize($controller));
|
|
|
|
$action = strtolower($action);
|
2020-10-31 10:26:33 +01:00
|
|
|
if ($checkLoggedActions) {
|
2020-09-28 17:48:34 +02:00
|
|
|
$this->__checkLoggedActions($user, $controller, $action);
|
|
|
|
}
|
2020-05-24 09:59:46 +02:00
|
|
|
if ($user && $user['Role']['perm_site_admin']) {
|
2018-07-19 11:48:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
2020-10-31 13:13:53 +01:00
|
|
|
$aclList = $this->__aclList;
|
|
|
|
foreach ($aclList as $k => $v) {
|
|
|
|
$aclList[$k] = array_change_key_case($v);
|
|
|
|
}
|
2018-07-19 11:48:22 +02:00
|
|
|
if (!isset($aclList[$controller])) {
|
2020-10-31 10:26:33 +01:00
|
|
|
$this->__error(404);
|
2018-07-19 11:48:22 +02:00
|
|
|
}
|
|
|
|
if (isset($aclList[$controller][$action]) && !empty($aclList[$controller][$action])) {
|
2020-10-31 10:26:33 +01:00
|
|
|
$rules = $aclList[$controller][$action];
|
|
|
|
if (in_array('*', $rules)) {
|
2018-07-19 11:48:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
2020-10-31 10:26:33 +01:00
|
|
|
if (isset($rules['OR'])) {
|
|
|
|
foreach ($rules['OR'] as $permission) {
|
2020-10-31 13:57:32 +01:00
|
|
|
if (isset($this->dynamicChecks[$permission])) {
|
|
|
|
if ($this->dynamicChecks[$permission]($user)) {
|
2020-08-21 13:41:48 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ($user['Role'][$permission]) {
|
|
|
|
return true;
|
|
|
|
}
|
2018-07-19 11:48:22 +02:00
|
|
|
}
|
|
|
|
}
|
2020-10-31 10:26:33 +01:00
|
|
|
} elseif (isset($rules['AND'])) {
|
2018-07-19 11:48:22 +02:00
|
|
|
$allConditionsMet = true;
|
2020-10-31 10:26:33 +01:00
|
|
|
foreach ($rules['AND'] as $permission) {
|
2020-10-31 13:57:32 +01:00
|
|
|
if (isset($this->dynamicChecks[$permission])) {
|
|
|
|
if (!$this->dynamicChecks[$permission]($user)) {
|
2020-08-21 13:41:48 +02:00
|
|
|
$allConditionsMet = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!$user['Role'][$permission]) {
|
|
|
|
$allConditionsMet = false;
|
|
|
|
}
|
2018-07-19 11:48:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($allConditionsMet) {
|
|
|
|
return true;
|
|
|
|
}
|
2020-10-31 13:57:32 +01:00
|
|
|
} elseif (isset($this->dynamicChecks[$rules[0]])) {
|
|
|
|
if ($this->dynamicChecks[$rules[0]]($user)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} elseif ($user['Role'][$rules[0]]) {
|
2018-07-19 11:48:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2020-10-31 10:26:33 +01:00
|
|
|
$this->__error(403);
|
2018-07-19 11:48:22 +02:00
|
|
|
}
|
2016-06-04 01:08:16 +02:00
|
|
|
|
2020-10-31 10:26:33 +01:00
|
|
|
/**
|
|
|
|
* @param int $code
|
|
|
|
* @throws InternalErrorException|MethodNotAllowedException|NotFoundException
|
|
|
|
*/
|
|
|
|
private function __error($code)
|
2018-07-19 11:48:22 +02:00
|
|
|
{
|
|
|
|
switch ($code) {
|
|
|
|
case 404:
|
2020-10-31 10:26:33 +01:00
|
|
|
throw new NotFoundException('Invalid controller.');
|
2018-07-19 11:48:22 +02:00
|
|
|
case 403:
|
2020-10-31 10:26:33 +01:00
|
|
|
throw new MethodNotAllowedException('You do not have permission to use this functionality.');
|
2018-07-19 11:48:22 +02:00
|
|
|
default:
|
2020-10-31 10:26:33 +01:00
|
|
|
throw new InternalErrorException('Unknown error');
|
2018-07-19 11:48:22 +02:00
|
|
|
}
|
|
|
|
}
|
2016-06-04 01:08:16 +02:00
|
|
|
|
2018-07-19 11:48:22 +02:00
|
|
|
private function __findAllFunctions()
|
|
|
|
{
|
|
|
|
$functionFinder = '/function[\s\n]+(\S+)[\s\n]*\(/';
|
|
|
|
$dir = new Folder(APP . 'Controller');
|
|
|
|
$files = $dir->find('.*\.php');
|
|
|
|
$results = array();
|
|
|
|
foreach ($files as $file) {
|
|
|
|
$controllerName = lcfirst(str_replace('Controller.php', "", $file));
|
|
|
|
if ($controllerName === 'app') {
|
|
|
|
$controllerName = '*';
|
|
|
|
}
|
|
|
|
$functionArray = array();
|
|
|
|
$fileContents = file_get_contents(APP . 'Controller' . DS . $file);
|
|
|
|
$fileContents = preg_replace('/\/\*[^\*]+?\*\//', '', $fileContents);
|
|
|
|
preg_match_all($functionFinder, $fileContents, $functionArray);
|
|
|
|
foreach ($functionArray[1] as $function) {
|
2018-08-31 16:08:46 +02:00
|
|
|
if (substr($function, 0, 1) !== '_' && $function !== 'beforeFilter' && $function !== 'afterFilter') {
|
2018-07-19 11:48:22 +02:00
|
|
|
$results[$controllerName][] = $function;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $results;
|
|
|
|
}
|
2016-06-04 01:08:16 +02:00
|
|
|
|
2018-07-19 11:48:22 +02:00
|
|
|
public function printAllFunctionNames($content = false)
|
|
|
|
{
|
|
|
|
$results = $this->__findAllFunctions();
|
|
|
|
ksort($results);
|
|
|
|
return $results;
|
|
|
|
}
|
2016-04-18 03:19:01 +02:00
|
|
|
|
2018-07-19 11:48:22 +02:00
|
|
|
public function findMissingFunctionNames($content = false)
|
|
|
|
{
|
|
|
|
$results = $this->__findAllFunctions();
|
|
|
|
$missing = array();
|
|
|
|
foreach ($results as $controller => $functions) {
|
|
|
|
foreach ($functions as $function) {
|
|
|
|
if (!isset($this->__aclList[$controller])
|
|
|
|
|| !in_array($function, array_keys($this->__aclList[$controller]))) {
|
|
|
|
$missing[$controller][] = $function;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $missing;
|
|
|
|
}
|
2016-06-04 01:08:16 +02:00
|
|
|
|
2018-07-19 11:48:22 +02:00
|
|
|
public function printRoleAccess($content = false)
|
|
|
|
{
|
|
|
|
$results = array();
|
|
|
|
$this->Role = ClassRegistry::init('Role');
|
|
|
|
$conditions = array();
|
|
|
|
if (is_numeric($content)) {
|
|
|
|
$conditions = array('Role.id' => $content);
|
|
|
|
}
|
|
|
|
$roles = $this->Role->find('all', array(
|
|
|
|
'recursive' => -1,
|
|
|
|
'conditions' => $conditions
|
|
|
|
));
|
|
|
|
if (empty($roles)) {
|
|
|
|
throw new NotFoundException('Role not found.');
|
|
|
|
}
|
|
|
|
foreach ($roles as $role) {
|
|
|
|
$urls = $this->__checkRoleAccess($role['Role']);
|
|
|
|
$results[$role['Role']['id']] = array('name' => $role['Role']['name'], 'urls' => $urls);
|
|
|
|
}
|
|
|
|
return $results;
|
|
|
|
}
|
2016-06-04 01:08:16 +02:00
|
|
|
|
2020-10-31 17:43:14 +01:00
|
|
|
private function __checkRoleAccess(array $role)
|
2018-07-19 11:48:22 +02:00
|
|
|
{
|
|
|
|
$result = array();
|
2020-10-31 17:43:14 +01:00
|
|
|
$fakeUser = ['Role' => $role, 'org_id' => Configure::read('MISP.host_org_id')];
|
2018-07-19 11:48:22 +02:00
|
|
|
foreach ($this->__aclList as $controller => $actions) {
|
2020-10-31 17:43:14 +01:00
|
|
|
$controllerNames = Inflector::variable($controller) === Inflector::underscore($controller) ?
|
|
|
|
array(Inflector::variable($controller)) :
|
|
|
|
array(Inflector::variable($controller), Inflector::underscore($controller));
|
2018-07-19 11:48:22 +02:00
|
|
|
foreach ($controllerNames as $controllerName) {
|
|
|
|
foreach ($actions as $action => $permissions) {
|
2020-10-31 17:43:14 +01:00
|
|
|
if ($this->canUserAccess($fakeUser, $controllerName, $action)) {
|
|
|
|
$result[] = "/$controllerName/$action";
|
2018-07-19 11:48:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
2016-06-06 10:09:55 +02:00
|
|
|
}
|