Skip to content

Commit

Permalink
Merge pull request #52 from slackerzz/fix_graphql_response
Browse files Browse the repository at this point in the history
avoid to inject code in graphql responses
  • Loading branch information
slackerzz authored Sep 1, 2021
2 parents 182da02 + c3210f5 commit aa4112d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@

namespace MSP\DevTools\Model;

use Magento\Framework\App\Area;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Request\Http;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\State;
use Magento\Framework\Autoload\AutoloaderRegistry;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\HTTP\PhpEnvironment\RemoteAddress;
Expand Down Expand Up @@ -64,6 +66,11 @@ class Config
*/
private $request;

/**
* @var State
*/
private $state;

protected $isActive = null;
protected $isEnabled = null;

Expand All @@ -72,14 +79,16 @@ public function __construct(
RequestInterface $request,
RemoteAddress $remoteAddress,
DirectoryList $directoryList,
Http $http
Http $http,
State $state
) {

$this->scopeConfig = $scopeConfig;
$this->remoteAddress = $remoteAddress;
$this->directoryList = $directoryList;
$this->http = $http;
$this->request = $request;
$this->state = $state;
}

/**
Expand Down Expand Up @@ -240,7 +249,8 @@ public function canInjectCode()
if (
(!$this->request->getParam('isAjax') || ($this->request->getParam('isAjax') == 'false')) &&
($requestedWith != 'xmlhttprequest') &&
(strpos($requestedWith, 'shockwaveflash') === false)
(strpos($requestedWith, 'shockwaveflash') === false &&
$this->state->getAreaCode() !== Area::AREA_GRAPHQL)
) {
$this->canInjectCode = true;
}
Expand Down

0 comments on commit aa4112d

Please sign in to comment.