mirror of https://github.com/itflow-org/itflow
Fix credential vars in Services
This commit is contained in:
parent
c1c54780cb
commit
15aed891f4
|
|
@ -28,23 +28,23 @@ if ($service_importance == "High") {
|
|||
$service_importance_display = "-";
|
||||
}
|
||||
|
||||
// Associated Assets (and their logins/networks/locations)
|
||||
// Associated Assets (and their credentials/networks/locations)
|
||||
$sql_assets = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_assets
|
||||
LEFT JOIN assets ON service_assets.asset_id = assets.asset_id
|
||||
LEFT JOIN asset_interfaces ON interface_asset_id = assets.asset_id AND interface_primary = 1
|
||||
LEFT JOIN logins ON service_assets.asset_id = logins.login_asset_id
|
||||
LEFT JOIN credentials ON service_assets.asset_id = credentials.credential_asset_id
|
||||
LEFT JOIN networks ON interface_network_id = networks.network_id
|
||||
LEFT JOIN locations ON assets.asset_location_id = locations.location_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
|
||||
// Associated logins
|
||||
$sql_logins = mysqli_query(
|
||||
// Associated credentials
|
||||
$sql_credentials = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_logins
|
||||
LEFT JOIN logins ON service_logins.login_id = logins.login_id
|
||||
"SELECT * FROM service_credentials
|
||||
LEFT JOIN credentials ON service_credentials.credential_id = credentials.credential_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
|
||||
|
|
@ -318,27 +318,27 @@ ob_start();
|
|||
}
|
||||
?>
|
||||
|
||||
<!-- Logins -->
|
||||
<!-- Credentials -->
|
||||
<?php
|
||||
if (mysqli_num_rows($sql_assets) > 0 || mysqli_num_rows($sql_logins) > 0) { ?>
|
||||
<h5><i class="fas fa-fw fa-key mr-2"></i>Logins</h5>
|
||||
if (mysqli_num_rows($sql_assets) > 0 || mysqli_num_rows($sql_credentials) > 0) { ?>
|
||||
<h5><i class="fas fa-fw fa-key mr-2"></i>Credentials</h5>
|
||||
<ul>
|
||||
<?php
|
||||
// Reset the $sql_assets/logins pointer to the start
|
||||
// Reset the $sql_assets/credentials pointer to the start
|
||||
mysqli_data_seek($sql_assets, 0);
|
||||
mysqli_data_seek($sql_logins, 0);
|
||||
mysqli_data_seek($sql_credentials, 0);
|
||||
|
||||
// Showing logins linked to assets
|
||||
// Showing credentials linked to assets
|
||||
while ($row = mysqli_fetch_array($sql_assets)) {
|
||||
if (!empty($row['login_name'])) {
|
||||
echo "<li><a href=\"credentials.php?client_id=$client_id&q=$row[login_name]\">$row[login_name]</a></li>";
|
||||
echo "<li><a href=\"credentials.php?client_id=$client_id&q=$row[credential_name]\">$row[credential_name]</a></li>";
|
||||
}
|
||||
}
|
||||
|
||||
// Showing explicitly linked logins
|
||||
while ($row = mysqli_fetch_array($sql_logins)) {
|
||||
if (!empty($row['login_name'])) {
|
||||
echo "<li><a href=\"credentials.php?client_id=$client_id&q=$row[login_name]\">$row[login_name]</a></li>";
|
||||
// Showing explicitly linked credentials
|
||||
while ($row = mysqli_fetch_array($sql_credentials)) {
|
||||
if (!empty($row['credential_name'])) {
|
||||
echo "<li><a href=\"credentials.php?client_id=$client_id&q=$row[credential_name]\">$row[credential_name]</a></li>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -349,27 +349,27 @@ ob_start();
|
|||
|
||||
<!-- URLs -->
|
||||
<?php
|
||||
if ($sql_logins || $sql_assets) { ?>
|
||||
if ($sql_credentials || $sql_assets) { ?>
|
||||
<h5><i class="fas fa-fw fa-link mr-2"></i>URLs</h5>
|
||||
<ul>
|
||||
<?php
|
||||
// Reset the $sql_logins pointer to the start
|
||||
mysqli_data_seek($sql_logins, 0);
|
||||
// Reset the $sql_credentials pointer to the start
|
||||
mysqli_data_seek($sql_credentials, 0);
|
||||
|
||||
// Showing URLs linked to logins
|
||||
while ($row = mysqli_fetch_array($sql_logins)) {
|
||||
if (!empty($row['login_uri'])) {
|
||||
echo "<li><a href=\"https://$row[login_uri]\">$row[login_uri]</a></li>";
|
||||
// Showing URLs linked to credentials
|
||||
while ($row = mysqli_fetch_array($sql_credentials)) {
|
||||
if (!empty($row['credential_uri'])) {
|
||||
echo "<li><a href=\"https://$row[credential_uri]\">$row[credential_uri]</a></li>";
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the $sql_assets pointer to the start
|
||||
mysqli_data_seek($sql_assets, 0);
|
||||
|
||||
// Show URLs linked to assets, that also have logins
|
||||
// Show URLs linked to assets, that also have credentials
|
||||
while ($row = mysqli_fetch_array($sql_assets)) {
|
||||
if (!empty($row['login_uri'])) {
|
||||
echo "<li><a href=\"https://$row[login_uri]\">$row[login_uri]</a></li>";
|
||||
if (!empty($row['credential_uri'])) {
|
||||
echo "<li><a href=\"https://$row[credential_uri]\">$row[credential_uri]</a></li>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -190,14 +190,14 @@
|
|||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="logins">Select related logins</label>
|
||||
<select class="form-control select2" id="logins" name="logins[]" multiple>
|
||||
<label for="logins">Select related Credentials</label>
|
||||
<select class="form-control select2" id="credentials" name="credentials[]" multiple>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM logins WHERE login_archived_at IS NULL AND login_client_id = $client_id");
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM credentials WHERE credential_archived_at IS NULL AND credential_client_id = $client_id");
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$login_id = intval($row['login_id']);
|
||||
$login_name = nullable_htmlentities($row['login_name']);
|
||||
echo "<option value=\"$login_id\">$login_name</option>";
|
||||
$credential_id = intval($row['credential_id']);
|
||||
$credential_name = nullable_htmlentities($row['credential_name']);
|
||||
echo "<option value=\"$credential_id\">$credential_name</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -43,15 +43,15 @@ if (isset($_POST['add_asset'])) {
|
|||
|
||||
|
||||
if (!empty($_POST['username'])) {
|
||||
$username = trim(mysqli_real_escape_string($mysqli, encryptLoginEntry($_POST['username'])));
|
||||
$password = trim(mysqli_real_escape_string($mysqli, encryptLoginEntry($_POST['password'])));
|
||||
$username = trim(mysqli_real_escape_string($mysqli, encryptCredentialEntry($_POST['username'])));
|
||||
$password = trim(mysqli_real_escape_string($mysqli, encryptCredentialEntry($_POST['password'])));
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO logins SET login_name = '$name', login_username = '$username', login_password = '$password', login_asset_id = $asset_id, login_client_id = $client_id");
|
||||
mysqli_query($mysqli,"INSERT INTO credentials SET credential_name = '$name', credential_username = '$username', credential_password = '$password', credential_asset_id = $asset_id, credential_client_id = $client_id");
|
||||
|
||||
$login_id = mysqli_insert_id($mysqli);
|
||||
$credential_id = mysqli_insert_id($mysqli);
|
||||
|
||||
//Logging
|
||||
logAction("Credential", "Create", "$session_name created login credential for asset $asset_name", $client_id, $login_id);
|
||||
logAction("Credential", "Create", "$session_name created login credential for asset $asset_name", $client_id, $credential_id);
|
||||
|
||||
$alert_extended = " along with login credentials";
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue