예제 #1
0
     $empty = POST('empty') != '' ? TRUE : FALSE;
     ossim_valid($name, OSS_ALPHA, OSS_PUNC, 'illegal:' . _('Group Name'));
     ossim_valid($descr, OSS_ALL, OSS_NULLABLE, 'illegal:' . _('Group Description'));
     if (ossim_error()) {
         Util::response_bad_request(ossim_get_error_clean());
     }
     try {
         $db = new ossim_db();
         $conn = $db->connect();
         $num_assets = Filter_list::get_total_selection($conn, 'asset');
         $id = Util::uuid();
         $ctx = Session::get_default_ctx();
         $asset_group = new Asset_group($id);
         $asset_group->set_name($name);
         $asset_group->set_descr($descr);
         $asset_group->set_ctx($ctx);
         $asset_group->save_in_db($conn);
         if (!$empty) {
             $asset_group->save_assets_from_search($conn, FALSE);
         }
         $db->close();
         $data['status'] = 'success';
         $data['data'] = sprintf(_('Asset group has been created in %s'), $app_name);
         $data['id'] = $id;
     } catch (Exception $e) {
         Util::response_bad_request(_('Error! Asset group could not be created') . ': ' . $e->getMessage());
     }
     break;
 case 'delete_group':
     $group_id = POST('asset_id');
     if (!valid_hex32($group_id)) {
function save_filter($conn, $filters, $data)
{
    //Getting the number of filters to be applied of the group
    $cont = $filters->get_num_filter_added();
    //We need at least one, otherwise we show an error.
    if ($cont < 1) {
        $return['error'] = TRUE;
        $return['msg'] = _('At least one filter needed');
        return $return;
    }
    $name = utf8_decode($data['name']);
    $descr = utf8_decode($data['descr']);
    ossim_valid($name, OSS_NOECHARS, OSS_ALPHA, OSS_PUNC, 'illegal:' . _('Group Name'));
    ossim_valid($descr, OSS_ALPHA, OSS_NULLABLE, OSS_PUNC, OSS_AT, OSS_NL, 'illegal:' . _('Description'));
    if (ossim_error()) {
        $response['error'] = TRUE;
        $response['msg'] = ossim_get_error();
        ossim_clean_error();
        return $response;
    }
    //Trying to save the filters, in case of error an exception will arise
    try {
        $new_id = Util::uuid();
        $ctx = Session::get_default_ctx();
        $group = new Asset_group($new_id);
        $group->set_name($name);
        $group->set_descr($descr);
        $group->set_ctx($ctx);
        $group->save_in_db($conn);
        $group->save_assets_from_search($conn);
        $filters->empty_filter_search($conn);
        $return['error'] = FALSE;
        $return['id'] = $new_id;
        $return['msg'] = 'ok';
        Asset_filter_list::delete_filters_from_session();
    } catch (Exception $e) {
        $return['error'] = TRUE;
        $return['msg'] = $e->getMessage();
    }
    return $return;
}
예제 #3
0
             if ($h_data['status'] == 'warning') {
                 $data['general']['status'] = 'warning';
                 $data['general']['data'] = _('Hosts saved with warnings');
                 break;
             }
         }
     } else {
         $data['general']['status'] = 'warning';
         $data['general']['data'] = _('Warning! Some hosts could not be saved');
     }
     //Create a Asset Group
     if (!empty($group_name)) {
         $new_group_id = Util::uuid();
         $group = new Asset_group($new_group_id);
         $group->set_name($group_name);
         $group->set_ctx($ctx);
         $group->save_in_db($conn);
         $group->save_assets_from_list($conn, $data['general']['hosts_in_group']);
     }
 }
 /*
 echo '<pre style="white-space: pre;">';
     print_r($data);
     print_r($scan_results);   
 echo '</pre>';         
 */
 //Showing scan results
 ?>
    
 <div id="summary_container">