Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
radicle: Only sign known refs
Alexis Sellier committed 3 years ago
commit 7d68df86d18ed2e2698289cf2e424ab9b5472b6c
parent 1f711b394a48dd74849ebdaa00f8e15fc87395b6
1 file changed +14 -3
modified radicle/src/storage/git.rs
@@ -440,7 +440,6 @@ impl ReadRepository for Repository {
    }

    fn references_of(&self, remote: &RemoteId) -> Result<Refs, Error> {
-
        // TODO: Only return known refs, eg. heads/ rad/ tags/ etc..
        let entries = self
            .backend
            .references_glob(format!("refs/namespaces/{remote}/*").as_str())?;
@@ -451,8 +450,20 @@ impl ReadRepository for Repository {
            let name = e.name().ok_or(Error::InvalidRef)?;
            let (_, refname) = git::parse_ref::<RemoteId>(name)?;
            let oid = e.target().ok_or(Error::InvalidRef)?;
-

-
            refs.insert(refname.into(), oid.into());
+
            let (_, category, _, _) = refname.non_empty_components();
+

+
            // Only sign known ref categories.
+
            if [
+
                git::name::HEADS,
+
                git::name::TAGS,
+
                git::name::NOTES,
+
                &git::name::component!("rad"),
+
                &git::name::component!("cobs"),
+
            ]
+
            .contains(&category.as_ref())
+
            {
+
                refs.insert(refname.into(), oid.into());
+
            }
        }
        Ok(refs.into())
    }