(c *C)
| 193 | } |
| 194 | |
| 195 | func (s *SubmoduleSuite) TestGitSubmodulesSymlink(c *C) { |
| 196 | // Plant the malicious symlink directly on the inner filesystem. |
| 197 | // The worktreeFilesystem wrapper's Symlink rejects .gitmodules |
| 198 | // link names by design (see validSymlinkName); the read-side |
| 199 | // detection in Submodules() is the layer being exercised here, |
| 200 | // so the setup goes through the unwrapped billy.Filesystem. |
| 201 | fs := s.Worktree.Filesystem |
| 202 | if wfs, ok := fs.(*worktreeFilesystem); ok { |
| 203 | fs = wfs.Filesystem |
| 204 | } |
| 205 | |
| 206 | f, err := fs.Create("badfile") |
| 207 | c.Assert(err, IsNil) |
| 208 | defer func() { _ = f.Close() }() |
| 209 | |
| 210 | err = fs.Remove(gitmodulesFile) |
| 211 | c.Assert(err, IsNil) |
| 212 | |
| 213 | err = fs.Symlink("badfile", gitmodulesFile) |
| 214 | c.Assert(err, IsNil) |
| 215 | |
| 216 | _, err = s.Worktree.Submodules() |
| 217 | c.Assert(err, Equals, ErrGitModulesSymlink) |
| 218 | } |
| 219 | |
| 220 | func (s *SubmoduleSuite) TestSubmodulesStatus(c *C) { |
| 221 | sm, err := s.Worktree.Submodules() |
nothing calls this directly
no test coverage detected