Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion rust/crates/greenbone-scanner-framework/src/get_scans_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ where
Box::pin(async move {
enforce_client_id_and_scan_id(&client_id, id, gsp.as_ref(), async |id| {
match gsp.get_scans_id(id).await {
Ok(x) => BodyKind::json_content(StatusCode::OK, &x),
Ok(mut x) => {
x.target.credentials = x
.clone()
.target
.credentials
.into_iter()
.map(|c| c.hide_pass())
.collect();
BodyKind::json_content(StatusCode::OK, &x)
}
Err(e) => e.into(),
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,88 @@ impl AsRef<str> for CredentialType {
}
}
}

impl CredentialType {
pub fn hide_pass(&mut self) -> Self {
match self {
CredentialType::UP {
username,
privilege,
..
} => {
let pr = match privilege {
Some(x) => Some(PrivilegeInformation {
username: x.username.clone(),
password: "".to_string(),
}),
None => None,
};

Self::UP {
username: username.to_string(),
password: "".to_string(),
privilege: pr,
}
}
CredentialType::USK {
username,
password,
privilege,
private_key,
} => {
let pr = match privilege {
Some(x) => Some(PrivilegeInformation {
username: x.username.clone(),
password: "".to_string(),
}),
None => None,
};
if let Some(p) = password.as_mut() {
p.clear();
};

CredentialType::USK {
username: username.to_string(),
password: password.clone(),
privilege: pr,
private_key: private_key.to_string(),
}
}
CredentialType::SNMP {
username,
auth_algorithm,
privacy_algorithm,
community,
..
} => CredentialType::SNMP {
username: username.to_string(),
password: "".to_string(),
privacy_password: "".to_string(),
privacy_algorithm: privacy_algorithm.to_string(),
auth_algorithm: auth_algorithm.to_string(),
community: community.to_string(),
},

CredentialType::KRB5 {
username,
realm,
kdc,
..
} => CredentialType::KRB5 {
username: username.to_string(),
password: String::new(),
realm: realm.to_string(),
kdc: kdc.to_string(),
},
}
}
}

impl Credential {
pub fn hide_pass(mut self) -> Self {
Self {
credential_type: self.credential_type.hide_pass(),
..self
}
}
}
Loading