News for hackers. Stuff that matters.
Re:Stepping Away from Sass by marcus_holmes on Thursday April 25, 2019 @10:09PM (#19754260)
>>Does a preprocessor really complicate the workflow?

I've just spent yesterday getting sass to work with my Golang project.

I used to have a nice simple makefile task, that compiled the project (in a split second) and launched it on localhost so I could find out where the problems were. My only dependency was the Go compiler. If I changed the css, the next page refresh sorted it.

Now I have a "sass watch" task, which compiles the scss to css. But that requires node.js, and npm (there are golang scss compilers, but all of them are either not being maintained, or have problems, or only support older versions of scss). I have to run this in a separate terminal so I can stop it when I need to.

I've deliberately not looked at my global node_modules directory. If I don't look, I don't have to worry about how many js libraries just got installed on my machine, and I don't have to think about who's maintaining them, and if they're now malicious. As long as sass only touches the css files, and css isn't Turing-complete (yet), then I don't need to audit any of that, and I can assume that it's not injecting malicious code into my application.

Though there are possible attacks on my site that could originate with code injection from a $malicious_left_pad js library, even via css, but it's enough of a stretch that my paranoia can live with it. I can check out the compressed css every now and again and see that it's not importing anything it shouldn't, and be reasonably sure that I haven't just compromised all my users' security.

So yeah, it's not so much that a preprocessor is a complication, it's that a preprocessor allows a malicious package to compile whatever it likes into files that I will then serve from my domain to my users, who trust that I'm not serving them malicious files. That's policed not at all by npm, or any of the package managers, who cheerfully assume that all javascript developers are honest.

Re:Stepping Away from Sass by stephenr on Thursday April 25, 2019 @11:02PM (#19754493)
Use sassc and call it from your makefile.
Re:Stepping Away from Sass by jayshua on Thursday April 25, 2019 @11:29PM (#19754615)
Not sure what it's like today, but last time I tried to use sassc it was a nightmare. The official repo was just the library with no CLI. I couldn't find a CLI that didn't also require me to compile it myself. Very frustrating.
Re:Stepping Away from Sass by wutwut5521 on Thursday April 25, 2019 @11:33PM (#19754633)
You might be thinking of libsass. sassc is dead simple and solves all of this users issues.
Re:Stepping Away from Sass by jayshua on Thursday April 25, 2019 @11:44PM (#19754674)
Correct me if I'm wrong, but doesn't sassc require the user to compile it?
Re:Stepping Away from Sass by wutwut5521 on Friday April 26, 2019 @10:48AM (#19758082)
You have to compile it, just like this poster has to compile their go code. There are usually packages and formulas for it in most std repos.
Re:Stepping Away from Sass by tangue on Friday April 26, 2019 @12:13AM (#19754818)
You're right, on OSX you can brew install sassc
Re:Stepping Away from Sass by marcus_holmes on Friday April 26, 2019 @01:25AM (#19755051)
there's a Debian package :) thanks for the tip :)
Re:Stepping Away from Sass by marcus_holmes on Friday April 26, 2019 @06:17AM (#19756046)
just got this working with fswatch and sassc, thought I'd feed back that this is perfect, thanks :)
Re:Stepping Away from Sass by wutwut5521 on Friday April 26, 2019 @10:46AM (#19758067)
Heh, I just woke up and read this and thought “well thats enough problem solving for today” :) Glad we could help you avoid the hell that is adding npm to a non-node project!
Re:Stepping Away from Sass by mercer on Saturday April 27, 2019 @04:48PM (#19767540)
Another thank you from here! I've had to use node just for sass in the past and this is a much nicer solution.
Re:Stepping Away from Sass by sureaboutthis on Friday April 26, 2019 @08:18AM (#19756652)
So a tool to fix the tool that's supposed to make things better.
Re:Stepping Away from Sass by stephenr on Friday April 26, 2019 @02:03PM (#19760235)
Huh?

SassC is just a cli tool that uses the C-language SASS library. It's an alternative to using whatever ridiculous NodeJS solution was/is being used.

Re:Stepping Away from Sass by speleding on Friday April 26, 2019 @04:46AM (#19755723)
I've been using the ruby Sass gem instead of the NPM version (https://sass-lang.com/ruby-sass). That prevents having to do the whole node thing. I know they say the ruby version is in maintenance mode, but for 99% of the use cases that's fine, it's been battle tested for years and Sass doesn't change that often anymore.
Re:Stepping Away from Sass by yawaramin on Thursday April 25, 2019 @11:35PM (#19754638)
> I can assume that it's not injecting malicious code into my application.

You don't need to assume, npm has an audit command that helps figure out if any of your package dependencies have reported vulnerabilities: https://docs.npmjs.com/cli/audit

Does Go?

Re:Stepping Away from Sass by marcus_holmes on Friday April 26, 2019 @01:18AM (#19755029)
useful, I didn't know about this. Thanks. How does the reporting of vulnerabilities work for npm?

No, Golang doesn't, but then it doesn't have a registry like npm in the first place. Gophers tend not to use third-party libraries if at all possible.

Re:Stepping Away from Sass by justinclift on Friday April 26, 2019 @03:29AM (#19755473)
> Gophers tend not to use third-party libraries if at all possible.

That sounds weird to me. It's pretty rare (almost never?) for applications to do useful things without third party libraries. eg any database access, input validation, making sure HTML output isn't malicious, etc.

Maybe that's just me though?

Re:Stepping Away from Sass by marcus_holmes on Friday April 26, 2019 @06:25AM (#19756078)
Go has an awesome standard library that does most stuff.

There's also a set of "semi-official" libraries for things like crypto that can't be written by amateurs ;)

There are some other libraries that are commonly used, but you can count them on one hand.

I'm a massive convert to this. Instead of spending my time working out how to get two 3rd-party libraries to talk to each other, I spend my time writing domain-specific code. and my debugging time is spent in repo's that I have a hope of understanding because I wrote them ;)

It doesn't suit everyone, and there are frequent rants on golang forums about people not importing dependencies. But every gopher seems to go through the same journey, and end up at a place where they just write their own code rather than importing it.

Re:Stepping Away from Sass by jcr1488 on Saturday April 27, 2019 @11:17PM (#19769112)
What's even more weird is making every 10 line function a "library" and the average program having 500+ dependencies. JS people are so hung up on "re-usability" that they completely miss the concept of dependency hygiene.
Re:Stepping Away from Sass by yawaramin on Friday April 26, 2019 @06:40PM (#19762372)
Re:Stepping Away from Sass by thecatspaw on Friday April 26, 2019 @03:01AM (#19755377)
isnt it very common to use github repositories as a library? I seem to recall that this was the way to get libraries, though it has been a few years since I looked into go
Re:Stepping Away from Sass by marcus_holmes on Friday April 26, 2019 @06:20AM (#19756064)
yes, but there's not an actual "registry" as such. Just a bunch of sites that have "useful go library" links.
Re:Stepping Away from Sass by type0 on Friday April 26, 2019 @05:11AM (#19755817)
I find that https://github.com/wellington/go-libsass is usually good enough for Go projects.
Re:Stepping Away from Sass by marcus_holmes on Friday April 26, 2019 @06:19AM (#19756061)
yeah, I looked at that, but a few things put me off (unmaintained, old version of scss, some caveats in the readme, etc).

Just got sassc working instead, so happy again hehe