Skip to content

Commit

Permalink
add profile id
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxudo committed Jan 8, 2024
1 parent db38e36 commit eaee07e
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 26 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ Table Schema
* profile_verification_state - varchar(255) - Profile's verification state
* user - varchar(255) - User that the profile belongs to
* profile_description - mediumtext - Profile's description
* profile_method - varchar(255) - If profile is emulated MCX or native mobile configuration profile
* profile_method - varchar(255) - If profile is emulated MCX or native mobile configuration profile
* profile_id - varchar(255) - Profile identifier
3 changes: 2 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
"profilename": "Profile Name",
"payloadname": "Payload Name",
"report": "Profile Report",
"profile_id": "Profile Identifier",
"profile_organization": "Profile Organization",
"profile_verification_state": "Profile Verification",
"profile_install_date": "Install Date",
"profile_removal_allowed": "Removal Allowed",
"profile_description": "Profile Description",
"payload_data": "Payload Data",
"payload_type": "Payload Type",
"payload_type": "Payload Domain",
"scope": "Scope",
"not_verified": "Not Verified",
"verified": "Verified",
Expand Down
25 changes: 25 additions & 0 deletions migrations/2024_01_07_000001_profile_add_profile_id.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Capsule\Manager as Capsule;

class ProfileAddProfileId extends Migration
{
private $tableName = 'profile';

public function up()
{
$capsule = new Capsule();
$capsule::schema()->table($this->tableName, function (Blueprint $table) {
$table->string('profile_id')->nullable();
});
}

public function down()
{
$capsule = new Capsule();
$capsule::schema()->table($this->tableName, function (Blueprint $table) {
$table->dropColumn('profile_id');
});
}
}
2 changes: 1 addition & 1 deletion profile_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function get_data($serial_number = '')
// Remove non-serial number characters
$serial_number = preg_replace("/[^A-Za-z0-9_\-]]/", '', $serial_number);

$sql = "SELECT profile_name, profile_uuid, user, profile_method, payload_name, payload_display, serial_number, profile_removal_allowed, profile_install_date, profile_organization, profile_verification_state, profile_description
$sql = "SELECT profile_name, profile_uuid, user, profile_method, payload_name, profile_id, payload_display, serial_number, profile_removal_allowed, profile_install_date, profile_organization, profile_verification_state, profile_description
FROM profile
WHERE serial_number = '$serial_number';";

Expand Down
5 changes: 3 additions & 2 deletions profile_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class Profile_model extends \Model
{
public function __construct($serial = '')
{
parent::__construct('id', 'profile'); //primary key, tablename
parent::__construct('id', 'profile'); // Primary key, tablename
$this->rs['id'] = '';
$this->rs['serial_number'] = $serial;
$this->rs['profile_uuid'] = '';
$this->rs['profile_name'] = '';
$this->rs['profile_removal_allowed'] = ''; //Yes or No (not a boolean)
$this->rs['profile_removal_allowed'] = ''; // Yes or No (not a boolean)
$this->rs['payload_name'] = '';
$this->rs['payload_display'] = '';
$this->rs['payload_data'] = '';
Expand All @@ -22,6 +22,7 @@ public function __construct($serial = '')
$this->rs['user'] = '';
$this->rs['profile_description'] = '';
$this->rs['profile_method'] = '';
$this->rs['profile_id'] = '';

if ($serial) {
$this->retrieve_record($serial);
Expand Down
8 changes: 6 additions & 2 deletions scripts/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def get_profiles_data(cachedir):
profile['profile_removal_allowed'] = ''
profile['profile_install_date'] = ''
profile['profile_method'] = "Native"
profile['profile_id'] = ''

# Process each user's profile data
for item in inner_user:
Expand All @@ -66,8 +67,10 @@ def get_profiles_data(cachedir):
profile['profile_verification_state'] = inner_user[item]
elif item == 'ProfileUninstallPolicy' or item == 'ProfileRemovalDisallowed':
profile['profile_removal_allowed'] = inner_user[item]
elif item == 'ProfileIdentifier' or item == 'ProfileRemovalDisallowed':
profile['profile_id'] = inner_user[item]
elif item == 'ProfileInstallDate':
installed = str(inner_user[item])
installed = str(inner_user[item])
date_str, tz = installed[:-5], installed[-5:]
dt_utc = datetime.strptime(date_str.strip(), "%Y-%m-%d %H:%M:%S")
dt = dt_utc.replace(tzinfo=FixedOffset(tz))
Expand Down Expand Up @@ -149,6 +152,7 @@ def get_profiles_data(cachedir):
profile['profile_method'] = "Emulated"
profile['user'] = "System Level"
profile['profile_removal_allowed'] = "true"
profile['profile_id'] = ''
for item in localProfilePlist:
# Reset keys for next payload
profile['payload_data'] = 'No Payload Data' # Set default payload_data value
Expand All @@ -166,7 +170,7 @@ def get_profiles_data(cachedir):
profile['payload_data'] = json.dumps(localProfilePlist[item][key],indent=2,default=str)
except:
profile['payload_data'] = 'Error Saving Payload Data'

# Add profile to profile_data
profile_data.append(profile.copy())

Expand Down
21 changes: 11 additions & 10 deletions views/profile_listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<th data-i18n="listing.computername" data-colname='machine.computer_name'></th>
<th data-i18n="serial" data-colname='reportdata.serial_number'></th>
<th data-i18n="profile.profilename" data-colname='profile.profile_name'></th>
<th data-i18n="profile.profile_id" data-colname='profile.profile_id'></th>
<th data-i18n="profile.uuid" data-colname='profile.profile_uuid'></th>
<th data-i18n="profile.scope" data-colname='profile.user'></th>
<th data-i18n="profile.method" data-colname='profile.profile_method'></th>
Expand All @@ -24,7 +25,7 @@
</thead>
<tbody>
<tr>
<td data-i18n="listing.loading" colspan="13" class="dataTables_empty"></td>
<td data-i18n="listing.loading" colspan="14" class="dataTables_empty"></td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -95,15 +96,15 @@
$('td:eq(0)', nRow).html(link);

// payload_display
var payload_display=$('td:eq(6)', nRow).text();
var payload_display=$('td:eq(7)', nRow).text();
(payload_display = payload_display == 'No Payload Display Name' ? i18n.t('') : payload_display)
$('td:eq(6)', nRow).text(payload_display)
$('td:eq(7)', nRow).text(payload_display)

// View payload data button
var profile_name=$('td:eq(2)', nRow).text();
var profile_uuid=$('td:eq(3)', nRow).text();
var payload_type=$('td:eq(6)', nRow).text();
$('td:eq(8)', nRow).html('<button onclick="view_payload_data(\''+sn+'\',\''+profile_uuid+'\',\''+payload_type+'\',\''+profile_name+'\')" class="btn btn-info btn-xs" style="min-width: 100px;" >'+i18n.t('profile.view')+'</button>')
var profile_uuid=$('td:eq(4)', nRow).text();
var payload_type=$('td:eq(7)', nRow).text();
$('td:eq(9)', nRow).html('<button onclick="view_payload_data(\''+sn+'\',\''+profile_uuid+'\',\''+payload_type+'\',\''+profile_name+'\')" class="btn btn-info btn-xs" style="min-width: 100px;" >'+i18n.t('profile.view')+'</button>')

// // profile_removal_allowed
// var removal_allowed=$('td:eq(9)', nRow).text();
Expand All @@ -118,19 +119,19 @@
// $('td:eq(9)', nRow).text(removal_allowed)

// Format profile_install_date
var event = parseInt($('td:eq(9)', nRow).text());
var event = parseInt($('td:eq(10)', nRow).text());
if (event){
var date = new Date(event * 1000);
$('td:eq(9)', nRow).html('<span title="' + moment(date).fromNow() + '">'+moment(date).format('llll')+'</span>');
$('td:eq(10)', nRow).html('<span title="' + moment(date).fromNow() + '">'+moment(date).format('llll')+'</span>');
}

// profile_verification_state
var verification_state=$('td:eq(11)', nRow).text();
var verification_state=$('td:eq(12)', nRow).text();
verification_state = verification_state == 'verified' ? i18n.t('profile.verified') :
verification_state = verification_state == 'signed' ? i18n.t('profile.verified') :
verification_state = verification_state == 'not verified' ? i18n.t('profile.not_verified') :
(verification_state = verification_state == 'unsigned' ? i18n.t('profile.not_verified') : verification_state)
$('td:eq(11)', nRow).text(verification_state)
$('td:eq(12)', nRow).text(verification_state)
}
});
});
Expand Down
20 changes: 11 additions & 9 deletions views/profile_tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<thead>
<tr>
<th data-i18n="profile.profilename" data-colname='profile.profile_name'></th>
<th data-i18n="profile.profile_id" data-colname='profile.profile_id'></th>
<th data-i18n="profile.uuid" data-colname='profile.profile_uuid'></th>
<th data-i18n="profile.scope" data-colname='profile.user'></th>
<th data-i18n="profile.method" data-colname='profile.profile_method'></th>
Expand All @@ -21,7 +22,7 @@
</thead>
<tbody>
<tr>
<td data-i18n="listing.loading" colspan="11" class="dataTables_empty"></td>
<td data-i18n="listing.loading" colspan="12" class="dataTables_empty"></td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -53,6 +54,7 @@
autoWidth: false,
columns: [
{ data: 'profile_name' },
{ data: 'profile_id' },
{ data: 'profile_uuid' },
{ data: 'user' },
{ data: 'profile_method'},
Expand All @@ -73,10 +75,10 @@
// View payload data button
var profile_name=$('td:eq(0)', nRow).text();
var profile_uuid=$('td:eq(1)', nRow).text();
var payload_type=$('td:eq(4)', nRow).text();
var sn=$('td:eq(6)', nRow).text();
$('td:eq(6)', nRow).html('<button onclick="view_payload_data(\''+sn+'\',\''+profile_uuid+'\',\''+payload_type+'\',\''+profile_name+'\')" class="btn btn-info btn-xs" style="min-width: 100px;" >'+i18n.t('profile.view')+'</button>')
var profile_uuid=$('td:eq(2)', nRow).text();
var payload_type=$('td:eq(5)', nRow).text();
var sn=$('td:eq(7)', nRow).text();
$('td:eq(7)', nRow).html('<button onclick="view_payload_data(\''+sn+'\',\''+profile_uuid+'\',\''+payload_type+'\',\''+profile_name+'\')" class="btn btn-info btn-xs" style="min-width: 100px;" >'+i18n.t('profile.view')+'</button>')
// // profile_removal_allowed
// var removal_allowed=$('td:eq(7)', nRow).text();
Expand All @@ -91,19 +93,19 @@
// $('td:eq(7)', nRow).text(removal_allowed)
// Format profile_install_date
var event = parseInt($('td:eq(7)', nRow).text());
var event = parseInt($('td:eq(8)', nRow).text());
if (event){
var date = new Date(event * 1000);
$('td:eq(7)', nRow).html('<span title="' + moment(date).fromNow() + '">'+moment(date).format('llll')+'</span>');
$('td:eq(8)', nRow).html('<span title="' + moment(date).fromNow() + '">'+moment(date).format('llll')+'</span>');
}
// profile_verification_state
var verification_state=$('td:eq(9)', nRow).text();
var verification_state=$('td:eq(10)', nRow).text();
verification_state = verification_state == 'verified' ? i18n.t('profile.verified') :
verification_state = verification_state == 'signed' ? i18n.t('profile.verified') :
verification_state = verification_state == 'not verified' ? i18n.t('profile.not_verified') :
(verification_state = verification_state == 'unsigned' ? i18n.t('profile.not_verified') : verification_state)
$('td:eq(9)', nRow).text(verification_state)
$('td:eq(10)', nRow).text(verification_state)
}
});
}
Expand Down

0 comments on commit eaee07e

Please sign in to comment.