Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing variable assignments before reference: ServerShell.php - issue : 9072 #9073

Open
wants to merge 1 commit into
base: 2.4
Choose a base branch
from

Conversation

kindtrojan
Copy link

@kindtrojan kindtrojan commented May 11, 2023

missing variable assignments before reference.

What does it do?

github issue: #9072

Questions

  • [No] Does it require a DB change?
  • [No] Are you using it in production?
  • [No] Does it require a change in the API (PyMISP for example)?

missing variable assignments before reference.
$syncTool = new SyncTool();
$server = $this->getServer($serverId);
$HttpSocket = $syncTool->setupHttpSocket($server);

$result = $this->TaxiiServer->push($serverId, $technique, $jobId, $HttpSocket, $user);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at app/Model/TaxiiServer.php:push(), I think the fix should actually be to change the arguments to
$result = $this->TaxiiServer->push($serverId, $user, $jobId);

With that, I managed to make the execution of a Taxii push go further, but I'm now hitting another exception
Error Call to a member function saveField() on null....
EDIT: I think this is because the Job is not created because calling push() skips the call pushRouter() which does create the Job.

EDIT2: Actually not specifying the $jobId and let it default to null seems to work better since this will force the creation of a new Job.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Thanks @VincentEggerling , maybe you are right.
I was skeptical of changing the function signature.
I will take a look again.

How are you debugging the MISP run? is there a debug switch/config somewhere that I couldnt find?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can "in live" tweak the .php files and add something like $this->log("Some var = " . $var, LOG_WARNING); Then have a look in app/tmp/logs and sort by most recently modified. You should see your log appear somewhere.
I use warning level to be sure the log appear because sometimes lower level log are ignored.

With this change, I was able to push some events to my TAXII server. However you might need some more tweaks such as:

You might still get errors coming from the conversion MISP->STIX2.1, currently I'm fighting with error of conversion when some GalaxyCluster are involved. (This will appear in the log exec-errors.log).

  • pip install --upgrade stix2 could maybe help ?
  • You can also tweak the conversion file app/files/scripts/taxii/taxii_push.py and add some log.warning().
  • You might want to comment out the reraise part
    raise FileProcessingError(event_file, str(e)) from e
    so that the conversion will still proceed even if one file fail to be converted.

This is really hacky for now. For some reason MISP creates two jobs when you click the "Push to TAXII" icon. One of them fails immediately, while the other if you're lucky will end up in "Completed" but still with a grey progression bar.
I think this is because the button triggers two different execution path that both create a job. (See Administration -> Jobs)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a very detailed explanation. Thank you very much.

I will give this a try.
I had shelved the MISP <-> TAXII integration efforts due to the bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants