Correction to upload so zip only ticked when malware and not when

attachement.
pull/61/head
noud 2012-07-10 11:39:43 +02:00
parent 1a56db0aac
commit 8f4727e3ad
3 changed files with 48 additions and 16 deletions

View File

@ -297,8 +297,8 @@ class AttributesController extends AppController {
$types = $this->Attribute->category_definitions[$category]['types'];
$alreadySet = false;
foreach ($types as $type) {
if (in_array($type, $this->Attribute->upload_definitions) && !$alreadySet) {
// add to the whole..207.204.231.231
if ($this->Attribute->typeIsAttachment($type) && !$alreadySet) {
// add to the whole..
$selectedCategories[] = $category;
$alreadySet = true;
continue;
@ -313,6 +313,7 @@ class AttributesController extends AppController {
$this->set('type_definitions', $this->Attribute->type_definitions);
$this->set('category_definitions', $this->Attribute->category_definitions);
$this->set('zipped_definitions', $this->Attribute->zipped_definitions);
$this->set('upload_definitions', $this->Attribute->upload_definitions);
}

View File

@ -33,11 +33,16 @@ class Attribute extends AppModel {
'private' => array('desc' => 'Prevents upload of this single Attribute to other CyDefSIG servers', 'formdesc' => 'Prevents upload of <em>this single Attribute</em> to other CyDefSIG servers.<br/>Used only when the Event is NOT set as Private')
);
// if these then a category my have upload to be zipped
public $zipped_definitions = array(
'malware-sample'
);
// if these then a category my have upload
public $upload_definitions = array(
'attachment',
'malware-sample'
'attachment'
);
// these are definition of possible types + their descriptions and maybe LATER other behaviors
@ -557,11 +562,16 @@ class Attribute extends AppModel {
return $similar_events;
}
function typeIsAttachment($type) {
if (in_array($type, $this->upload_definitions)) return true;
function typeIsMalware($type) {
if (in_array($type, $this->zipped_definitions)) return true;
else return false;
}
function typeIsAttachment($type) {
if ((in_array($type, $this->zipped_definitions)) || (in_array($type, $this->upload_definitions))) return true;
else return false;
}
function base64EncodeAttachment($attribute) {
$filepath = APP."files/".$attribute['event_id']."/".$attribute['id'];
$file = new File($filepath);

View File

@ -10,12 +10,12 @@
));
echo $this->Form->input('malware', array(
'type' => 'checkbox',
'checked' => true,
'checked' => false,
'after' => '<br>Tick this box to neutralize the sample. Every malware sample will be zipped with the password "infected"',
));
if ('true' == Configure::read('CyDefSIG.sync')) {
echo $this->Form->input('private', array(
'before' => $this->Html->div('forminfo', isset($attr_descriptions['private']['formdesc']) ? $attr_descriptions['private']['formdesc'] : $attr_descriptions['private']['desc']),));
if ('true' == Configure::read('CyDefSIG.sync')) {
echo $this->Form->input('private', array(
'before' => $this->Html->div('forminfo', isset($attr_descriptions['private']['formdesc']) ? $attr_descriptions['private']['formdesc'] : $attr_descriptions['private']['desc']),));
}
// link an onchange event to the form elements
$this->Js->get('#AttributeType')->event('change', 'showFormInfo("#AttributeType")');
@ -45,7 +45,7 @@ var formTypeValues = new Array();
$types = $def['types'];
$alreadySet = false;
foreach ($types as $type) {
if (in_array($type, $upload_definitions) && !$alreadySet) {
if (in_array($type, $zipped_definitions) && !$alreadySet) {
$alreadySet = true;
echo "formTypeValues['$category'] = \"true\";\n";
}
@ -53,6 +53,22 @@ var formTypeValues = new Array();
}
?>
function showFormType(id) {
idDiv = id+'Div';
// LATER use nice animations
//$(idDiv).hide('fast');
// change the content
var value = $(id).val(); // get the selected value
//$(idDiv).html(formInfoValues[value]); // search in a lookup table
// do checkbox un/ticked when the document is changed
if (formTypeValues[value] == "true") {
document.getElementById("AttributeMalware").setAttribute("checked", "checked");
} else {
document.getElementById("AttributeMalware").removeAttribute("checked");
}
}
function showFormInfo(id) {
idDiv = id+'Div';
// LATER use nice animations
@ -64,17 +80,22 @@ function showFormInfo(id) {
// show it again
$(idDiv).fadeIn('slow');
// do/not show upload
// do checkbox un/ticked when the document is changed
if (formTypeValues[value] == "true") {
$('div.upload').show();
document.getElementById("AttributeMalware").setAttribute("checked", "checked");
} else {
$('div.upload').hide();
}
document.getElementById("AttributeMalware").removeAttribute("checked");
}
}
// hide the formInfo things
$('#AttributeTypeDiv').hide();
$('#AttributeCategoryDiv').hide();
$(function(){
// do checkbox un/ticked when the document is ready
showFormType("#AttributeCategory");
}
);
</script>
<?php echo $this->Js->writeBuffer(); // Write cached scripts ?>