Giter Site home page Giter Site logo

bo's Introduction

Screenshot 2023-05-01 at 17 54 02

bo's People

Contributors

brouberol avatar cgg avatar dependabot[bot] avatar ilmanzo avatar jim4067 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

bewiwi agrism cgg

bo's Issues

Improve type system around Position/Coordinates

Coordinates have been tricky to get right for multiple reasons:

  • termion assumes 1-based coordinates, because this is what ANSI assumes (see https://docs.rs/termion/1.5.6/termion/cursor/struct.Goto.html), whereas Editor.cursor_position assumes 0-based coordinates.
  • I shoved a x_offset into the Position struct to account for the :ln induced x-shift, but Editor.offset (the viewport x/y offsets) has to use that x_offset attribute and always set it to 0 because it does not need it, as it's an attribute of type Position.

All of that is an open door to offset-related bugs, and has been pretty clunky to use. It just does not fit really well. I think we should redesign the type system into something like:

  • AnsiPosition{x, y}: represents the coordinates on screen, and conforms with ANSI by having its origin be (1, 1).
  • Position{x, y}: represents the current row/column as indices , ie:current_row = editor.document.rows[x] and current_grapheme = editor.documents.rows[x][y] (pseudocode). The goal is to never having to perform a (0,0)-based to (1,1)-based conversion (or conversely) in editor.rs.
  • ViewportOffset{x, y}: number of rows/columns the viewport has been shifted by (from a (0, 0) origin) to scope it to the current view.
  • Position.x_offset should be dropped, and an Editor.row_prefix_length u8 attribute should be introduced.

Let's play around with this, to see whether it makes the code easier to deal with, with less arithmetic and traps.

Undo fails on line deletion

How to reproduce

plop
lala

Go to line 2
type d
type u

The fact that the document has 1 line seems to clash with "re-growing" it back to 2. Probably because we send the line lengths to Operation.reversed().

Support line wrapping

By using a command, such as :wrap or :linewrap, we'd split lines exceeding the terminal width over multiple terminal lines.

This will probably be complex, as it'll have an impact on line numbering, the go_to_x_y mechanism, etc, so we'd need to find a lightweight solution to compute a document coordinate / terminal coordinate mapping, instead of re-computing it everytime, which would make every coordinate jump O(n).

RUSTSEC-2023-0018: Race Condition Enabling Link Following and Time-of-check Time-of-use (TOCTOU)

Race Condition Enabling Link Following and Time-of-check Time-of-use (TOCTOU)

Details
Package remove_dir_all
Version 0.5.3
URL XAMPPRocky/remove_dir_all@7247a8b
Date 2023-02-24
Patched versions >=0.8.0

The remove_dir_all crate is a Rust library that offers additional features over the Rust
standard library fs::remove_dir_all function.

It was possible to trick a privileged process doing a recursive delete in an
attacker controlled directory into deleting privileged files, on all operating systems.

For instance, consider deleting a tree called 'etc' in a parent directory
called 'p'. Between calling remove_dir_all("a") and remove_dir_all("a")
actually starting its work, the attacker can move 'p' to 'p-prime', and
replace 'p' with a symlink to '/'. Then the privileged process deletes 'p/etc'
which is actually /etc, and now your system is broken. There are some
mitigations for this exact scenario, such as CWD relative file lookup, but
they are not guaranteed - any code using absolute paths will not have that
protection in place.

The same attack could be performed at any point in the directory tree being
deleted: if 'a' contains a child directory called 'etc', attacking the
deletion by replacing 'a' with a link is possible.

The new code in this release mitigates the attack within the directory tree
being deleted by using file-handle relative operations: to open 'a/etc', the
path 'etc' relative to 'a' is opened, where 'a' is represented by a file
descriptor (Unix) or handle (Windows). With the exception of the entry points
into the directory deletion logic, this is robust against manipulation of the
directory hierarchy, and remove_dir_all will only delete files and directories
contained in the tree it is deleting.

The entry path however is a challenge - as described above, there are some
potential mitigations, but since using them must be done by the calling code,
it is hard to be confident about the security properties of the path based
interface.

The new extension trait RemoveDir provides an interface where it is much
harder to get it wrong.

somedir.remove_dir_contents("name-of-child").

Callers can then make their own security evaluation about how to securely get
a directory handle. That is still not particularly obvious, and we're going to
follow up with a helper of some sort (probably in the fs_at crate). Once
that is available, the path based entry points will get deprecated.

In the interim, processes that might run with elevated privileges should
figure out how to securely identify the directory they are going to delete, to
avoid the initial race. Pragmatically, other processes should be fine with the
path based entry points : this is the same interface std::fs::remove_dir_all
offers, and an unprivileged process running in an attacker controlled
directory can't do anything that the attacker can't already do.

See advisory page for additional details.

RUSTSEC-2021-0139: ansi_term is Unmaintained

ansi_term is Unmaintained

Details
Status unmaintained
Package ansi_term
Version 0.12.1
URL ogham/rust-ansi-term#72
Date 2021-08-18

The maintainer has adviced this crate is deprecated and will not
receive any maintenance.

The crate does not seem to have much dependencies and may or may not be ok to use as-is.

Last release seems to have been three years ago.

Possible Alternative(s)

The below list has not been vetted in any way and may or may not contain alternatives;

See advisory page for additional details.

Support edit actions specifiers

Commands such as dw, cb, dd, etc, have a prefix and a specifier. For example dw has the d (delete) prefix, and the w (word) specifier, meaning that we'd want to delete the next word. We could also have d} to delete the next paragraph, etc.

We should support such commands, that will get especially for yank/paste.

Add a command to rename/save as

Potential commands:

  • :saveas <filename>
  • :w <filename>

I think I prefer the second one, as it's what vim implements, and it's also more intuitive.

Terminal paste (`Ctrl + v`) "eats up" half of the characters.

Ctrl-v is a standard to paste the content of the clipboard, which sends the stream to the process' stdin. However pasting into bo` seems to only display .. half of these characters.

Demo

Pasting the word "Char" in bo, in INSERT mode

Screenshot 2021-09-02 at 19 49 11

Investigation

I was able to track down the issue to

let opt_key = io::stdin().lock().events().next();
. I added a utils:log call to print out the content of eachopt_key variable, wrapping the event, and I could only see half of the events being received:

$ tail -f bo.log
...
Some(Ok(Key(Char('i'))))  # switch to insert mode
Some(Ok(Key(Char('C'))))
Some(Ok(Key(Char('a'))))
...

So this looks like an issue with how we receive stdin events.

Support replacement of a search pattern

A possible syntax could be

/search_pattern

for simple search, and

/search_pattern/replace_by

We should probably handle / being part of the search pattern by escaping it: \/.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.